docker-compose.yml 3.12 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
16 17
    image: registry.gitlab.utc.fr/rex-dri/rex-dri/backend:v0.1.0
    # 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:
27
      # Add environment variables
Florent Chehab's avatar
Florent Chehab committed
28
      - ENV=DEV
29 30
      - SECRET_KEY=please_change_me  # Django secret key
      # Django admin user param
31 32
      - DJANGO_ADMIN_USERNAME=admin
      - DJANGO_ADMIN_PASSWORD=admin
33
      # DB parameters
Florent Chehab's avatar
Florent Chehab committed
34 35 36 37 38
      - DB_HOST=database
      - DB_PORT=5432
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
39 40
      # Specify host to wait for; ie we want to wait for the db for sure
      - WAIT_HOSTS=database:5432
41
    # Run the django developpement server on image startup.
42
    command: /bin/sh -c "/wait && cd backend && ./entry.sh"
Florent Chehab's avatar
Florent Chehab committed
43
    depends_on:
44
      # Required that the `database` and `frontend` service are up and running.
Florent Chehab's avatar
Florent Chehab committed
45
      - database
46
      - frontend
47

48
  # Service for the postgres database
Florent Chehab's avatar
Florent Chehab committed
49
  database:
50
    # Use of classic image
Florent Chehab's avatar
Florent Chehab committed
51 52
    image: postgres:10.5-alpine
    environment:
53
      # Set up the postgres ID
Florent Chehab's avatar
Florent Chehab committed
54 55 56 57
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    volumes:
58
      # Add a volume to store the DB data.
Florent Chehab's avatar
Florent Chehab committed
59
      - postgres_data:/var/lib/postgresql/data/
60

61
  # Service to handle frontend live developpments and building
Florent Chehab's avatar
Florent Chehab committed
62
  frontend:
63 64 65 66 67 68
    # 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
69
    volumes:
70
      # "Copy" the repo to the workdir.
Florent Chehab's avatar
Florent Chehab committed
71
      - .:/usr/src/app/
72 73
      # 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
74
    ports:
75 76
      # Replicate the node server port. More info in ./frontend/server.js
      - 3000:3000
77 78
      # replicate the view stats port
      - "8888:8888"
79 80

  # Service to provide a local documentation
81 82 83 84
  documentation:
    build: ./documentation
    volumes:
      - ./documentation:/usr/src/app
85
    # Start a simple python folder
86 87
    command: /bin/sh -c "python -m http.server 5000"
    ports:
88
      # replicate the server port
89
      - "5000:5000"
90 91 92

  # service to generate the UML of the backend
  gen_doc_uml:
93 94 95 96 97 98
    image: floawfloaw/plantuml
    volumes:
      - .:/usr/src/app
    command: tail -F anything # keep the container alive


99

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