diff --git a/.env.dev b/.env.dev index ec03959..79ada81 100644 --- a/.env.dev +++ b/.env.dev @@ -2,6 +2,7 @@ HOST=api.dev.sahkoinsinoorikilta.fi DEBUG=True SECRET_KEY=7p$85^4ibb^p4-=vs44b7!y0e-zemugze18@a#30&71=a8)dp( TG_BOT_TOKEN= +DB_NAME=postgres DB_USER=postgres DB_PASSWD=postgres DB_HOST=db diff --git a/.env.sample b/.env.sample index e78a331..f8194f9 100644 --- a/.env.sample +++ b/.env.sample @@ -2,6 +2,7 @@ HOST=localhost DEBUG=True SECRET_KEY=7p$85^4ibb^p4-=vs44b7!y0e-zemugze18@a#30&71=a8)dp( TG_BOT_TOKEN= +DB_NAME=postgres DB_USER=postgres DB_PASSWD=postgres DB_HOST=db diff --git a/production_entrypoint.sh b/production_entrypoint.sh index 6c13118..b943776 100755 --- a/production_entrypoint.sh +++ b/production_entrypoint.sh @@ -10,12 +10,6 @@ fi if test -f "$EMAIL_API_KEY_FILE"; then export EMAIL_API_KEY=$(cat $EMAIL_API_KEY_FILE) fi -# if test -f "$EMAIL_API_SECRET_FILE"; then -# export EMAIL_API_SECRET=$(cat $EMAIL_API_SECRET_FILE) -fi -if test -f "$DB_USER_FILE"; then - export DB_USER=$(cat $DB_USER_FILE) -fi if test -f "$DB_PASSWD_FILE"; then export DB_PASSWD=$(cat $DB_PASSWD_FILE) fi diff --git a/sikweb/settings.py b/sikweb/settings.py index 55acddb..93bc949 100644 --- a/sikweb/settings.py +++ b/sikweb/settings.py @@ -49,7 +49,7 @@ TELEGRAM_BOT_TOKEN = os.getenv('TG_BOT_TOKEN', '') DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': os.getenv('DB_USER', 'postgres'), + 'NAME': os.getenv('DB_NAME', 'postgres'), 'USER': os.getenv('DB_USER', 'postgres'), 'PASSWORD': os.getenv('DB_PASSWD', 'postgres'), 'HOST': os.getenv('DB_HOST', 'localhost'), diff --git a/stack-compose.yml b/stack-compose.yml index 81f9129..f5d9fb3 100644 --- a/stack-compose.yml +++ b/stack-compose.yml @@ -1,21 +1,5 @@ version: '3.4' services: - db: - image: postgres:12 - deploy: - replicas: 1 - - environment: - - POSTGRES_USER_FILE=/run/secrets/BACKEND_DB_USER - - POSTGRES_PASSWORD_FILE=/run/secrets/BACKEND_DB_PASSWD - ports: - - 5432:5432 - volumes: - - dbdata:/var/lib/postgresql/data - secrets: - - BACKEND_DB_USER - - BACKEND_DB_PASSWD - backend: image: registry.gitlab.com/sahkoinsinoorikilta/vtmk/web2.0-backend:latest deploy: @@ -28,30 +12,30 @@ services: - 8000:8000 volumes: - type: bind - source: /home/sik/production/files/static/.hidden/django/media + source: /home/sik/datadrive/production/files/static/.hidden/django/media target: /app/media - type: bind - source: /home/sik/production/files/static/.hidden/django/static + source: /home/sik/datadrive/production/files/static/.hidden/django/static target: /app/static - type: bind - source: /home/sik/production/files/static/.hidden/django/collected_static + source: /home/sik/datadrive/production/files/static/.hidden/django/collected_static target: /app/collected_static environment: - - SECRET_KEY_FILE=/run/secrets/BACKEND_SECRET_KEY - - TG_BOT_TOKEN_FILE=/run/secrets/BACKEND_TG_BOT_TOKEN - - DB_USER_FILE=/run/secrets/BACKEND_DB_USER - - DB_PASSWD_FILE=/run/secrets/BACKEND_DB_PASSWD - HOST=api.sahkoinsinoorikilta.fi - FRONTEND_URL=sahkoinsinoorikilta.fi - - DB_HOST=db + - DB_NAME=sik + - DB_USER=sik + - DB_HOST=managed-db.postgres.database.azure.com - DB_PORT=5432 + - SECRET_KEY_FILE=/run/secrets/BACKEND_SECRET_KEY + - TG_BOT_TOKEN_FILE=/run/secrets/BACKEND_TG_BOT_TOKEN + - DB_PASSWD_FILE=/run/secrets/BACKEND_DB_PASSWD - EMAIL_API_KEY_FILE=/run/secrets/BACKEND_EMAIL_API_KEY secrets: - BACKEND_SECRET_KEY - BACKEND_TG_BOT_TOKEN - - BACKEND_DB_USER - BACKEND_DB_PASSWD - BACKEND_EMAIL_API_KEY secrets: @@ -59,14 +43,7 @@ secrets: external: true BACKEND_TG_BOT_TOKEN: external: true - BACKEND_DB_NAME: - external: true - BACKEND_DB_USER: - external: true BACKEND_DB_PASSWD: external: true BACKEND_EMAIL_API_KEY: external: true - -volumes: - dbdata: