docker-compose.yml 2.4 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.

Florent Chehab's avatar
Florent Chehab committed
4 5 6
version: '3.7'

services:
7
  # Service for the backend app.
Florent Chehab's avatar
Florent Chehab committed
8
  backend:
9
    # Get the image from the registry
Florent Chehab's avatar
Florent Chehab committed
10
    image: registry.gitlab.utc.fr/rex-dri/rex-dri/backend:latest
11
    # To use a locally build one, comment above, uncomment bellow.
Florent Chehab's avatar
Florent Chehab committed
12 13
    # build: ./backend
    volumes:
14
      # "Copy" the repo to the workdir.
Florent Chehab's avatar
Florent Chehab committed
15 16
      - .:/usr/src/app/
    ports:
17 18
      # Replicate the python server port
      - 8000:8000
Florent Chehab's avatar
Florent Chehab committed
19
    environment:
20
      # Add environment variables
Florent Chehab's avatar
Florent Chehab committed
21
      - ENV=DEV
22 23
      - SECRET_KEY=please_change_me  # Django secret key
      # Django admin user param
24 25
      - DJANGO_ADMIN_USERNAME=admin
      - DJANGO_ADMIN_PASSWORD=admin
26
      # DB parameters
Florent Chehab's avatar
Florent Chehab committed
27 28 29 30 31
      - DB_HOST=database
      - DB_PORT=5432
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
32
    # Run the django developpement server on image startup.
33
    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
34
    depends_on:
35
      # Required that the `database` service is up and running.
Florent Chehab's avatar
Florent Chehab committed
36
      - database
37
  # Service for the postgres database
Florent Chehab's avatar
Florent Chehab committed
38
  database:
39
    # Use of classic image
Florent Chehab's avatar
Florent Chehab committed
40 41
    image: postgres:10.5-alpine
    environment:
42
      # Set up the postgres ID
Florent Chehab's avatar
Florent Chehab committed
43 44 45 46
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    volumes:
47
      # Add a volume to store the DB data.
Florent Chehab's avatar
Florent Chehab committed
48
      - postgres_data:/var/lib/postgresql/data/
49
  # Service to handle frontend live developpments and building
Florent Chehab's avatar
Florent Chehab committed
50
  frontend:
51
    # Build image from Dockerfile
Florent Chehab's avatar
Florent Chehab committed
52
    build: ./frontend
53
    # On startup, start the developpement server
Florent Chehab's avatar
Florent Chehab committed
54 55
    command: /bin/sh -c "cd frontend && npm i --verbose && npm run dev"
    volumes:
56
      # "Copy" the repo to the workdir.
Florent Chehab's avatar
Florent Chehab committed
57 58
      - .:/usr/src/app/
    ports:
59 60
      # Replicate the node server port. More info in ./frontend/server.js
      - 3000:3000
61 62
      # replicate the view stats port
      - "8888:8888"
63 64 65 66
  documentation:
    build: ./documentation
    volumes:
      - ./documentation:/usr/src/app
67
    # Start a simple python folder
68 69
    command: /bin/sh -c "python -m http.server 5000"
    ports:
70
      # replicate the server port
71
      - "5000:5000"
72

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