docker-compose.prod.yml 2.44 KB
Newer Older
1 2 3 4
version: "3.6"

networks:
  backend-db:
5
  map-nginx:
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

volumes:
  postgres_data_prod:
  uwsgi_socket_dir:
  django_logs:
  frontend_logs:
  nginx_logs:

services:
  backend:
    image: registry.gitlab.utc.fr/rex-dri/rex-dri/backend-prod:v0.2.1
    restart: on-failure
    volumes:
      - ../:/usr/src/app/
      - uwsgi_socket_dir:/usr/src/socket/
      - ./uwsgi/:/usr/src/uwsgi/:ro
      - django_logs:/var/log/django
      - frontend_logs:/var/log/frontend
24
    env_file: [./envs/db.env, ./envs/django.env, ./envs/external_data.env]
25 26 27 28 29 30 31 32 33 34 35 36 37 38
    environment:
      WAIT_HOSTS: database:5432  # For the 'wait' script, so that we are sure the db is up and running
      ENV: PROD  # make sure to be in prod env
    command: /bin/sh -c "/wait && cd backend && ./entry.sh && uwsgi --log-master --ini /usr/src/uwsgi/uwsgi.ini"
    networks: [backend-db]
    depends_on: [database, frontend] # - frontend

  database:
    image: postgres:10.5-alpine
    networks: [backend-db]
    env_file: [./envs/db.env]
    volumes: ["postgres_data_prod:/var/lib/postgresql/data/"]

  frontend: # Will be killed as soon as the front is generated
39
    image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v0.5.0
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    command: /bin/sh -c "cd frontend && cp -R /usr/src/deps/node_modules . && npm run build"
    volumes:
      - ../:/usr/src/app/
      - /usr/src/app/frontend/node_modules

  nginx:
    build:
      context: ./nginx
      dockerfile: prod.Dockerfile
    restart: always
    volumes:
      - uwsgi_socket_dir:/usr/src/socket/
      - ../backend/static/:/usr/src/static:ro
      - ../backend/media/:/usr/src/media:ro
      - nginx_logs:/var/log/nginx
    ports: ["80:80"]
56 57
    networks: [map-nginx]
    depends_on: [backend, map]
58 59
    command: [nginx-debug, '-g', 'daemon off;']

60 61 62 63 64 65 66
  map:
    image: "floawfloaw/light-world-tileserver:2019-05-21--zoom-${MAP_ZOOM_LEVEL}"
    networks: [map-nginx]
    volumes: ["./map:/data/custom:ro"]
    entrypoint: ["node", "/usr/src/app/", "-p", "8080", "--config", "/data/custom/config.json", "--public_url", "${MAP_PUBLIC_URL}", "--silent"]
    restart: always

67 68 69 70 71 72 73 74 75 76 77 78 79 80
  logs_rotation:
    image: blacklabelops/logrotate:1.3
    environment:
      LOGS_DIRECTORIES: /var/log/django /var/log/nginx /var/log/frontend
      LOGROTATE_INTERVAL: daily
      LOGROTATE_COPIES: 30
      LOGROTATE_COMPRESSION: compress
    volumes:
      - django_logs:/var/log/django
      - frontend_logs:/var/log/frontend
      - nginx_logs:/var/log/nginx
    depends_on:
      - nginx
      - backend