From 4b04178a4ff9d1bc43473e62231f2bb785666fbe Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Thu, 29 Jun 2023 09:35:24 +0200 Subject: [PATCH] Set env files explicitly --- docker-compose.development.yml | 5 +---- docker-compose.production.yml | 12 +++++++++++- docker-compose.yml | 14 ++++---------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/docker-compose.development.yml b/docker-compose.development.yml index a33740a..ce2b646 100644 --- a/docker-compose.development.yml +++ b/docker-compose.development.yml @@ -7,10 +7,9 @@ volumes: services: db: env_file: ./.development.env + celery: env_file: ./.development.env - environment: - - DJANGO_SETTINGS_MODULE=newsreader.conf.docker volumes: - ./src/:/app/src @@ -19,8 +18,6 @@ services: target: development command: python /app/src/manage.py runserver 0.0.0.0:8000 env_file: ./.development.env - environment: - - DJANGO_SETTINGS_MODULE=newsreader.conf.docker ports: - "${DJANGO_PORT:-8000}:8000" volumes: diff --git a/docker-compose.production.yml b/docker-compose.production.yml index aa442ad..9a53f8a 100644 --- a/docker-compose.production.yml +++ b/docker-compose.production.yml @@ -5,13 +5,23 @@ volumes: static-files: services: + db: + env_file: ./.production.env + + celery: + env_file: ./.production.env + + django: + env_file: ./.production.env + nginx: image: nginx:1.23 depends_on: django: condition: service_healthy - env_file: ./.env + env_file: ./.production.env ports: + # Note that --env-file should be used to set these correctly - "${NGINX_HTTP_PORT:-80}:80" volumes: - ./config/nginx/conf.d:/etc/nginx/conf.d diff --git a/docker-compose.yml b/docker-compose.yml index 28ecae6..3c5d74e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,11 +10,11 @@ services: db: image: postgres:15 healthcheck: - test: /usr/bin/pg_isready + # Note that --env-file should be used to set these correctly + test: /usr/bin/pg_isready --username="${POSTGRES_USER}" --dbname="${POSTGRES_DB}" interval: 5s timeout: 10s retries: 10 - env_file: ./.env volumes: - postgres-data:/var/lib/postgresql/data @@ -39,7 +39,7 @@ services: POSTGRES_USER: POSTGRES_PASSWORD: DJANGO_SECRET_KEY: - DJANGO_SETTINGS_MODULE: "newsreader.conf.production" + DJANGO_SETTINGS_MODULE: command: | celery worker -n worker1@%h -n worker2@%h @@ -49,9 +49,6 @@ services: --workdir /app/src/ --beat --scheduler django - env_file: ./.env - environment: - - DJANGO_SETTINGS_MODULE=newsreader.conf.production depends_on: rabbitmq: condition: service_started @@ -76,7 +73,7 @@ services: POSTGRES_USER: POSTGRES_PASSWORD: DJANGO_SECRET_KEY: - DJANGO_SETTINGS_MODULE: "newsreader.conf.production" + DJANGO_SETTINGS_MODULE: entrypoint: /app/bin/docker-entrypoint.sh command: | gunicorn --bind 0.0.0.0:8000 @@ -88,9 +85,6 @@ services: interval: 30s timeout: 10s retries: 10 - env_file: ./.env - environment: - - DJANGO_SETTINGS_MODULE=newsreader.conf.production depends_on: memcached: condition: service_started