docker-compose.yml 2.71 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 8
# Main ports summary:
# - 8000: main app
# - 5000: documentation


Florent Chehab's avatar
Florent Chehab committed
9 10 11
version: '3.7'

services:
12

13
  # Service for the backend app.
Florent Chehab's avatar
Florent Chehab committed
14
  backend:
15
    # Get the image from the registry
Florent Chehab's avatar
Florent Chehab committed
16
    image: registry.gitlab.utc.fr/rex-dri/rex-dri/backend:v0.1.3
17
    # To use a locally built one, comment above, uncomment bellow.
Florent Chehab's avatar
Florent Chehab committed
18
    # build: ./backend
19
    restart: on-failure
Florent Chehab's avatar
Florent Chehab committed
20
    volumes:
21
      # "Copy" the repo to the workdir.
Florent Chehab's avatar
Florent Chehab committed
22 23
      - .:/usr/src/app/
    ports:
24 25
      # Replicate the python server port
      - 8000:8000
Florent Chehab's avatar
Florent Chehab committed
26
    environment:
Florent Chehab's avatar
Florent Chehab committed
27 28 29 30
      WAIT_HOSTS: database:5432  # For the 'wait' script, so that we are sure the db is up and running
    env_file:
      - ./envs/db.env
      - ./envs/django.env
31
    # Run the django developpement server on image startup.
32
    command: /bin/sh -c "/wait && cd backend && ./entry.sh"
Florent Chehab's avatar
Florent Chehab committed
33
    depends_on:
34
      # Required that the `database` and `frontend` service are up and running.
Florent Chehab's avatar
Florent Chehab committed
35
      - database
36
      - frontend
37

38
  # Service for the postgres database
Florent Chehab's avatar
Florent Chehab committed
39
  database:
40
    # Use of classic image
Florent Chehab's avatar
Florent Chehab committed
41
    image: postgres:10.5-alpine
Florent Chehab's avatar
Florent Chehab committed
42 43
    env_file:
      - ./envs/db.env
Florent Chehab's avatar
Florent Chehab committed
44
    volumes:
45
      # Add a volume to store the DB data.
Florent Chehab's avatar
Florent Chehab committed
46
      - postgres_data:/var/lib/postgresql/data/
47

48
  # Service to handle frontend live developpments and building
Florent Chehab's avatar
Florent Chehab committed
49
  frontend:
50 51 52 53 54 55
    # Get the image from the registry
    image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v0.1.0
    # 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
56
    volumes:
57
      # "Copy" the repo to the workdir.
Florent Chehab's avatar
Florent Chehab committed
58
      - .:/usr/src/app/
59 60
      # 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
61
    ports:
62 63
      # Replicate the node server port. More info in ./frontend/server.js
      - 3000:3000
64 65
      # replicate the view stats port
      - "8888:8888"
66 67

  # Service to provide a local documentation
68 69 70 71
  documentation:
    build: ./documentation
    volumes:
      - ./documentation:/usr/src/app
72
    # Start a simple python folder
73 74
    command: /bin/sh -c "python -m http.server 5000"
    ports:
75
      # replicate the server port
76
      - "5000:5000"
77 78 79

  # service to generate the UML of the backend
  gen_doc_uml:
80 81 82 83 84 85
    image: floawfloaw/plantuml
    volumes:
      - .:/usr/src/app
    command: tail -F anything # keep the container alive


86

Florent Chehab's avatar
Florent Chehab committed
87
volumes:
88
  # Create some local volume (should be stored in some directory on your computer)
Florent Chehab's avatar
Florent Chehab committed
89
  postgres_data: