version: '3.4'
services:
  backend:
    image: registry.gitlab.com/sahkoinsinoorikilta/vtmk/web2.0-backend:latest
    deploy:
      replicas: 1
      update_config:
        order: start-first
    depends_on:
      - db
    ports:
      - 8000:8000
    volumes:
      - type: bind
        source: /home/sik/datadrive/production/files/static/.hidden/django/media
        target: /app/media
      - type: bind
        source: /home/sik/datadrive/production/files/static/.hidden/django/static
        target: /app/static
      - type: bind
        source: /home/sik/datadrive/production/files/static/.hidden/django/collected_static
        target: /app/collected_static

    environment:
      - HOST=api.sahkoinsinoorikilta.fi
      - FRONTEND_URL=sahkoinsinoorikilta.fi
      - DB_NAME=sik
      - DB_USER=sik
      - DB_HOST=managed-db.postgres.database.azure.com
      - DB_PORT=5432
      - DB_SSL=True
      - 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_PASSWD
      - BACKEND_EMAIL_API_KEY
secrets:
  BACKEND_SECRET_KEY:
    external: true
  BACKEND_TG_BOT_TOKEN:
    external: true
  BACKEND_DB_PASSWD:
    external: true
  BACKEND_EMAIL_API_KEY:
    external: true
