Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduction of DDE_DATA_HOME and Path Adjustments #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions commands/_internals/checkUpdate.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function _ddeCheckUpdate() {
local oldPwd=$(pwd)
cd ${ROOT_DIR}
if [ ! -f "${DATA_DIR}/.dde_update_check" ] || [ $(find "${DATA_DIR}/.dde_update_check" -mtime +1 -print) ]; then
if [ ! -f "${DDE_DATA_HOME}/.dde_update_check" ] || [ $(find "${DDE_DATA_HOME}/.dde_update_check" -mtime +1 -print) ]; then
_logYellow "Check if dde update is available"
git fetch || true # allow offline usage
touch ${DATA_DIR}/.dde_update_check
touch ${DDE_DATA_HOME}/.dde_update_check
fi

local upstream=${1:-'@{u}'}
Expand Down
34 changes: 34 additions & 0 deletions commands/_internals/createDataHome.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
_createDataHome() {
# Check if DDE_DATA_HOME is set
if [ -z "$DDE_DATA_HOME" ]; then
_logRed "DDE_DATA_HOME is not set."
return 1
fi

# Create the main directory if it doesn't exist
if [ ! -d "$DDE_DATA_HOME" ]; then
mkdir -p "$DDE_DATA_HOME"
fi

# Check if DATA_DIR exists
if [ -d "$DATA_DIR" ]; then
# Move contents of DATA_DIR to DDE_DATA_HOME
# Assuming DDE_DATA_HOME/data is the target directory
local targetDir="$DDE_DATA_HOME/data"
mkdir -p "$targetDir"
mv "$DATA_DIR/*" "$targetDir/"
fi

# Create config.yml if it doesn't exist
local configFile="$DDE_DATA_HOME/config.yml"
if [ ! -f "$configFile" ]; then
touch "$configFile"
fi

# Create dde.conf in the nginx conf.d directory if it doesn't exist
local nginxConfFile="$DDE_DATA_HOME/data/reverseproxy/etc/nginx/conf.d/dde.conf"
if [ ! -f "$nginxConfFile" ]; then
mkdir -p "$(dirname "$nginxConfFile")"
echo "client_max_body_size 100m;" > "$nginxConfFile"
fi
}
3 changes: 1 addition & 2 deletions commands/project/destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function project:destroy() {

for vhost in $(${DOCKER_COMPOSE} config | _yq_stdin e '.services.*.environment.VIRTUAL_HOST | select(length>0)'); do
_logYellow "Delete certs for ${vhost}"
rm -f ${CERT_DIR}/${vhost}.*
rm -f ${DDE_CERT_PATH}/${vhost}.*
done

if [ "${SYNC_MODE}" = "mutagen" ]; then
Expand All @@ -31,4 +31,3 @@ function project:destroy() {
function destroy() {
project:destroy
}

2 changes: 1 addition & 1 deletion commands/project/up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function project:up() {

_logYellow "Generating SSL cert"
for vhost in $(${DOCKER_COMPOSE} config | _yq_stdin e '.services.*.environment.VIRTUAL_HOST | select(length>0)'); do
${HELPER_DIR}/generate-vhost-cert.sh ${CERT_DIR} ${vhost}
${HELPER_DIR}/generate-vhost-cert.sh ${DDE_CERT_PATH} ${vhost}
done

if [ "${SYNC_MODE}" = "docker-sync" ]; then
Expand Down
1 change: 1 addition & 0 deletions commands/system/dde/install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## makes the setup for your shell

function system:dde:install() {
_createDataHome
system:dde:install:alias
}
8 changes: 5 additions & 3 deletions commands/system/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ function system:env() {
echo OSTYPE=${OSTYPE}
echo SOURCE=${SOURCE}
echo ROOT_DIR=${ROOT_DIR}
echo DATA_DIR=${DATA_DIR}
echo CERT_DIR=${CERT_DIR}
_logYellow "DATA_DIR (Deprecated, use DDE_DATA_HOME) = ${DATA_DIR}"
_logYellow "CERT_DIR (Deprecated, use DDE_CERT_PATH) = ${CERT_DIR}"
echo DDE_DATA_HOME=${DDE_DATA_HOME}
echo DDE_CERT_PATH=${DDE_CERT_PATH}
echo HELPER_DIR=${HELPER_DIR}
echo NETWORK_NAME=${NETWORK_NAME}
echo DOCKER_BUILDKIT=${DOCKER_BUILDKIT}
echo DDE_UID=${DDE_UID}
echo DDE_GID=${DDE_GID}
echo ""
_logGreen "Avialable services";
_logGreen "Available services"
system:services
}

Expand Down
7 changes: 3 additions & 4 deletions commands/system/up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ function system:up() {
fi

_logYellow "Creating CA cert if required"
mkdir -p ${CERT_DIR}
cd ${CERT_DIR}
mkdir -p ${DDE_CERT_PATH}
cd ${DDE_CERT_PATH}
if [ ! -f ca.pem ]; then
openssl genrsa -out ca.key 2048
openssl req -x509 -new -nodes -key ca.key -sha256 -days 3650 -subj "/C=CH/ST=Bern/L=Bern/O=dde/CN=dde" -out ca.pem
fi

_logYellow "Creating certs used by system services"
${HELPER_DIR}/generate-vhost-cert.sh ${CERT_DIR} mailhog.test
${HELPER_DIR}/generate-vhost-cert.sh ${DDE_CERT_PATH} mailhog.test

_logYellow "Starting containers"
cd ${ROOT_DIR}
Expand All @@ -44,4 +44,3 @@ function system:up() {
function system-up() {
system:up
}

1 change: 1 addition & 0 deletions commands/system/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function system:update() {
${DOCKER_COMPOSE} build --pull

_logYellow "Starting dde (system)"
_createDataHome
system:up

_logGreen "Finished update successfully"
Expand Down
Empty file removed data/.gitkeep
Empty file.
1 change: 0 additions & 1 deletion data/reverseproxy/etc/nginx/conf.d/dde.conf

This file was deleted.

6 changes: 6 additions & 0 deletions dde.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ HELP_DIR=${ROOT_DIR}/help
HELPER_DIR=${ROOT_DIR}/helper
NETWORK_NAME=dde
DOCKER_BUILDKIT=1


DDE_DATA_HOME="$HOME/.dde"
DDE_CERT_PATH="$DDE_DATA_HOME/data/reverseproxy/etc/nginx/certs"
DDE_UID=$(id -u)
DDE_GID=$(id -g)
DDE_BROWSER=
DDE_CONTAINER_SHELL=sh
export DDE_UID
export DDE_GID
export DDE_CONTAINER_SHELL
export DDE_DATA_HOME

# If we're running in CI we need to disable TTY allocation for docker-compose
# commands that enable it by default, such as exec and run.
TTY=""
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ services:
- SSL_POLICY=Mozilla-Modern
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./data/reverseproxy/etc/nginx/certs:/etc/nginx/certs:ro
- ./data/reverseproxy/etc/nginx/vhost.d:/etc/nginx/vhost.d:ro
- ./data/reverseproxy/etc/nginx/conf.d/dde.conf:/etc/nginx/conf.d/dde.conf:ro
- ${DDE_DATA_HOME}/data/reverseproxy/etc/nginx/certs:/etc/nginx/certs:ro
- ${DDE_DATA_HOME}/data/reverseproxy/etc/nginx/vhost.d:/etc/nginx/vhost.d:ro
- ${DDE_DATA_HOME}/data/reverseproxy/etc/nginx/conf.d/dde.conf:/etc/nginx/conf.d/dde.conf:ro
hostname: reverseproxy
domainname: test
container_name: dde_reverseproxy
Expand All @@ -39,7 +39,7 @@ services:
environment:
- MYSQL_ROOT_PASSWORD=root
volumes:
- ./data/mariadb/var/lib/mysql:/var/lib/mysql:delegated
- ${DDE_DATA_HOME}/data/mariadb/var/lib/mysql:/var/lib/mysql:delegated
hostname: mariadb
domainname: test
container_name: dde_mariadb
Expand All @@ -52,7 +52,7 @@ services:
- VIRTUAL_HOST=mailhog.test
- VIRTUAL_PORT=8025
volumes:
- ./data/mailhog/var/lib/mailhog:/var/lib/mailhog:delegated
- ${DDE_DATA_HOME}/data/mailhog/var/lib/mailhog:/var/lib/mailhog:delegated
ports:
- "127.0.0.1:1025:1025"
hostname: mailhog
Expand Down