docker-compose.yml 3.69 KB
Newer Older
1 2 3
# Main docker-compose file for the project to coordinate all the docker related stuff.
# To build from local image, use the `build: ...` attibute and not the `image` attribute.

4 5 6 7
# Main ports summary:
# - 8000: main app
# - 5000: documentation

Florent Chehab's avatar
Florent Chehab committed
8 9
version: '3.7'

10 11 12 13 14 15 16
volumes:
  # Create some local volume (should be stored in some directory on your computer)
  postgres_data:

networks:
  backend-nginx:
  backend-db:
17
  map-nginx:
18

Florent Chehab's avatar
Florent Chehab committed
19
services:
20

21
  # Service for the backend app.
Florent Chehab's avatar
Florent Chehab committed
22
  backend:
23
    # Get the image from the registry
24
    image: registry.gitlab.utc.fr/rex-dri/rex-dri/backend:v0.2.1
25
    # To use a locally built one, comment above, uncomment bellow.
Florent Chehab's avatar
Florent Chehab committed
26
    # build: ./backend
27
    restart: on-failure
28 29
    volumes: [".:/usr/src/app/"]  # "Copy" the repo to the workdir.
    networks: [backend-nginx, backend-db]
Florent Chehab's avatar
Florent Chehab committed
30
    environment:
31
      WAIT_HOSTS: database:5432  # For the 'wait' script, so that we are sure the db is up and running
32
    env_file: [./server/envs/db.env, ./server/envs/django.env, ./server/envs/external_data.env]
33
    # Run the django developpement server on image startup.
34 35 36 37 38 39 40 41 42 43 44 45 46
    command: /bin/sh -c "/wait && cd backend && ./entry.sh && ./manage.py runserver 0.0.0.0:8000 --nostatic"
    # Required that the `database` and `frontend` service are up and running.
    depends_on: [database, frontend]

  # Serve through nginx just like in a production env
  nginx:
    build:
      context: ./server/nginx
      dockerfile: dev.Dockerfile
    restart: always
    volumes:
      - ./backend/static/:/usr/src/static:ro
      - ./backend/media/:/usr/src/media:ro
47
    networks: [backend-nginx, map-nginx]
48 49 50 51
    ports:
      # The port 8000 of the host is redirected to the port 80 of the container
      # which then redirect it to the port 8000 of the backend container
      - 8000:80
52
    depends_on: [backend, map]
53

54
  # Service for the postgres database
Florent Chehab's avatar
Florent Chehab committed
55
  database:
56
    # Use of classic image
Florent Chehab's avatar
Florent Chehab committed
57
    image: postgres:10.5-alpine
58 59 60 61
    networks: [backend-db]
    ports: ["5432:5432"]
    env_file: [./server/envs/db.env]
    volumes: ["postgres_data:/var/lib/postgresql/data/"]  # Add a volume to store the DB data.
62

63
  # Service to handle frontend live developpments and building
Florent Chehab's avatar
Florent Chehab committed
64
  frontend:
65
    # Get the image from the registry
66
    image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v0.5.0
67 68 69 70
    # To use a locally built one, comment above, uncomment bellow.
    # build: ./frontend
    # On startup, we retrieve the dependencies from the image and start the developpement server
    command: /bin/sh -c "cd frontend && cp -R /usr/src/deps/node_modules . && npm run dev"
Florent Chehab's avatar
Florent Chehab committed
71
    volumes:
72
      # "Copy" the repo to the workdir.
Florent Chehab's avatar
Florent Chehab committed
73
      - .:/usr/src/app/
74 75
      # Ignore local node_modules: we will use the one from the docker image
      - /usr/src/app/frontend/node_modules
Florent Chehab's avatar
Florent Chehab committed
76
    ports:
77
      # Replicate the node server port (used for live/hot reloading). More info in ./frontend/server.js
78
      - 3000:3000
79 80
      # replicate the view stats port
      - "8888:8888"
81

82 83 84 85 86 87 88 89
  # Service to host map tiles
  map:
    image: floawfloaw/light-world-tileserver:2019-05-21--zoom-8
    networks: [map-nginx]
    volumes: ["./server/map:/data/custom:ro"]
    entrypoint: ["node", "/usr/src/app/", "-p", "8080", "--config", "/data/custom/config.json", "--public_url", "http://localhost:8000/map-server/", "--silent"]
    restart: always

90
  # Service to provide a local documentation
91 92
  documentation:
    build: ./documentation
93
    volumes: ["./documentation:/usr/src/app"]
94
    # Start a simple python folder
95
    command: /bin/sh -c "python -m http.server 5000"
96
    ports: ["5000:5000"]  # replicate the server port
97 98 99

  # service to generate the UML of the backend
  gen_doc_uml:
100
    image: floawfloaw/plantuml
101
    volumes: [".:/usr/src/app"]
102
    command: tail -F anything # keep the container alive