docker-compose.yml 2.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 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 && ./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` service is up and running.
Florent Chehab's avatar
Florent Chehab committed
42
      - database
43

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

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

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

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


91

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