docker-compose.yml 2.75 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:latest
17
    # To use a locally build one, comment above, uncomment bellow.
Florent Chehab's avatar
Florent Chehab committed
18 19
    # build: ./backend
    volumes:
20
      # "Copy" the repo to the workdir.
Florent Chehab's avatar
Florent Chehab committed
21 22
      - .:/usr/src/app/
    ports:
23 24
      # Replicate the python server port
      - 8000:8000
Florent Chehab's avatar
Florent Chehab committed
25
    environment:
26
      # Add environment variables
Florent Chehab's avatar
Florent Chehab committed
27
      - ENV=DEV
28 29
      - SECRET_KEY=please_change_me  # Django secret key
      # Django admin user param
30 31
      - DJANGO_ADMIN_USERNAME=admin
      - DJANGO_ADMIN_PASSWORD=admin
32
      # DB parameters
Florent Chehab's avatar
Florent Chehab committed
33 34 35 36 37
      - DB_HOST=database
      - DB_PORT=5432
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
38
    # Run the django developpement server on image startup.
39
    command: /bin/sh -c "cd backend && ./waitForFrontend.sh && ./manage.py collectstatic --noinput && ./manage.py runserver 0.0.0.0:8000"
Florent Chehab's avatar
Florent Chehab committed
40
    depends_on:
41
      # Required that the `database` and `frontend` service is up and running.
Florent Chehab's avatar
Florent Chehab committed
42
      - database
43
      - frontend
44

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

58
  # Service to handle frontend live developpments and building
Florent Chehab's avatar
Florent Chehab committed
59
  frontend:
60
    # Build image from Dockerfile
Florent Chehab's avatar
Florent Chehab committed
61
    build: ./frontend
62
    # On startup, start the developpement server
Florent Chehab's avatar
Florent Chehab committed
63 64
    command: /bin/sh -c "cd frontend && npm i --verbose && npm run dev"
    volumes:
65
      # "Copy" the repo to the workdir.
Florent Chehab's avatar
Florent Chehab committed
66 67
      - .:/usr/src/app/
    ports:
68 69
      # Replicate the node server port. More info in ./frontend/server.js
      - 3000:3000
70 71
      # replicate the view stats port
      - "8888:8888"
72 73

  # Service to provide a local documentation
74 75 76 77
  documentation:
    build: ./documentation
    volumes:
      - ./documentation:/usr/src/app
78
    # Start a simple python folder
79 80
    command: /bin/sh -c "python -m http.server 5000"
    ports:
81
      # replicate the server port
82
      - "5000:5000"
83 84 85

  # service to generate the UML of the backend
  gen_doc_uml:
86 87 88 89 90 91
    image: floawfloaw/plantuml
    volumes:
      - .:/usr/src/app
    command: tail -F anything # keep the container alive


92

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