diff --git a/.env.dev b/.env.dev index c4c8a0d35..3b195e275 100644 --- a/.env.dev +++ b/.env.dev @@ -1,7 +1,7 @@ COMPOSE_PROJECT_NAME=ghostfolio-development # CACHE -REDIS_HOST=localhost +REDIS_HOST=redis REDIS_PORT=6379 REDIS_PASSWORD= @@ -12,7 +12,7 @@ POSTGRES_PASSWORD= # VARIOUS ACCESS_TOKEN_SALT= -DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}?connect_timeout=300&sslmode=prefer +DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?connect_timeout=300&sslmode=prefer JWT_SECRET_KEY= # DEVELOPMENT diff --git a/docker/docker-compose.build.yml b/docker/docker-compose.build.yml index 96829ad34..7a53f15b4 100644 --- a/docker/docker-compose.build.yml +++ b/docker/docker-compose.build.yml @@ -6,10 +6,6 @@ services: init: true env_file: - ../.env - environment: - DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?connect_timeout=300&sslmode=prefer - REDIS_HOST: redis - REDIS_PASSWORD: ${REDIS_PASSWORD} ports: - 3333:3333 depends_on: @@ -24,12 +20,13 @@ services: retries: 5 postgres: - image: docker.io/library/postgres:15 + image: docker.io/library/postgres:15-alpine container_name: gf-postgres-build env_file: - ../.env healthcheck: - test: ['CMD-SHELL', 'pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}'] + test: + ['CMD-SHELL', 'pg_isready -d "$${POSTGRES_DB}" -U $${POSTGRES_USER}'] interval: 10s timeout: 5s retries: 5 @@ -41,9 +38,17 @@ services: container_name: gf-redis-build env_file: - ../.env - command: ['redis-server', '--requirepass', $REDIS_PASSWORD] + command: + - /bin/sh + - -c + # - Double dollars, so that the variable is not expanded by Docker Compose + # - Surround by quotes, so that the shell does not split the password + # - The ${variable:?message} syntax causes shell to exit with a non-zero + # code and print a message, when the variable is not set or empty + - redis-server --requirepass "$${REDIS_PASSWORD:?REDIS_PASSWORD variable is not set}" healthcheck: - test: ['CMD-SHELL', 'redis-cli --pass "$REDIS_PASSWORD" ping | grep PONG'] + test: + ['CMD-SHELL', 'redis-cli --pass "$${REDIS_PASSWORD}" ping | grep PONG'] interval: 10s timeout: 5s retries: 5 diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml index 39a1d56e9..5617e7806 100644 --- a/docker/docker-compose.dev.yml +++ b/docker/docker-compose.dev.yml @@ -1,7 +1,7 @@ name: ghostfolio_dev services: postgres: - image: docker.io/library/postgres:15 + image: docker.io/library/postgres:15-alpine container_name: gf-postgres-dev restart: unless-stopped env_file: @@ -17,7 +17,14 @@ services: restart: unless-stopped env_file: - ../.env - command: ['redis-server', '--requirepass', $REDIS_PASSWORD] + command: + - /bin/sh + - -c + # - Double dollars, so that the variable is not expanded by Docker Compose + # - Surround by quotes, so that the shell does not split the password + # - The ${variable:?message} syntax causes shell to exit with a non-zero + # code and print a message, when the variable is not set or empty + - redis-server --requirepass "$${REDIS_PASSWORD:?REDIS_PASSWORD variable is not set}" ports: - ${REDIS_PORT:-6379}:6379 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index bf3f8252e..fbeb21a75 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -19,7 +19,7 @@ services: redis: condition: service_healthy healthcheck: - test: [ 'CMD-SHELL', 'curl -f http://localhost:3333/api/v1/health' ] + test: ['CMD-SHELL', 'curl -f http://localhost:3333/api/v1/health'] interval: 10s timeout: 5s retries: 5 @@ -41,7 +41,8 @@ services: env_file: - ../.env healthcheck: - test: [ 'CMD-SHELL', 'pg_isready -d "$${POSTGRES_DB}" -U $${POSTGRES_USER}' ] + test: + ['CMD-SHELL', 'pg_isready -d "$${POSTGRES_DB}" -U $${POSTGRES_USER}'] interval: 10s timeout: 5s retries: 5 @@ -68,7 +69,8 @@ services: # code and print a message, when the variable is not set or empty - redis-server --requirepass "$${REDIS_PASSWORD:?REDIS_PASSWORD variable is not set}" healthcheck: - test: [ 'CMD-SHELL', 'redis-cli --pass "$${REDIS_PASSWORD}" ping | grep PONG' ] + test: + ['CMD-SHELL', 'redis-cli --pass "$${REDIS_PASSWORD}" ping | grep PONG'] interval: 10s timeout: 5s retries: 5