diff --git a/Docker/deploy_database.sh b/Docker/scripts/deploy_database.sh similarity index 90% rename from Docker/deploy_database.sh rename to Docker/scripts/deploy_database.sh index a478414a..4b08b5e8 100644 --- a/Docker/deploy_database.sh +++ b/Docker/scripts/deploy_database.sh @@ -1,6 +1,6 @@ #!/bin/bash -source ./scripts/env_functions.sh +source ./Docker/scripts/env_functions.sh if [ "$DOCKER_ENV" != "true" ]; then export_env_vars diff --git a/Docker/scripts/env_functions.sh b/Docker/scripts/env_functions.sh new file mode 100755 index 00000000..c2720e90 --- /dev/null +++ b/Docker/scripts/env_functions.sh @@ -0,0 +1,18 @@ +export_env_vars() { + if [ -f .env ]; then + while IFS='=' read -r key value; do + if [[ -z "$key" || "$key" =~ ^\s*# || -z "$value" ]]; then + continue + fi + + key=$(echo "$key" | tr -d '[:space:]') + value=$(echo "$value" | tr -d '[:space:]') + value=$(echo "$value" | tr -d "'" | tr -d "\"") + + export "$key=$value" + done < .env + else + echo ".env file not found" + exit 1 + fi +} diff --git a/Dockerfile b/Dockerfile index ef28a3e3..670b7a70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,11 +27,11 @@ COPY ./.env.example ./.env COPY ./Docker ./Docker -RUN chmod +x ./Docker/deploy_database.sh +RUN chmod +x ./Docker/scripts/* ENV DATABASE_CONNECTION_URI=postgres://postgres:pass@localhost/evolution -RUN ./Docker/deploy_database.sh +RUN ./Docker/scripts/deploy_database.sh RUN npm run build