docker-compose.yaml 3.74 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
# docker-compose configuration to build a local development installation of the failmap platform.

version: "3"
services:
  # message broker to distribute tasks
  broker:
    image: redis
    # this containers logging is not really that interesting during development
    logging:
      driver: none
    # Not configuring persistent storage for broker. Restarting will cause all unfinished
    # tasks to be forgotten, instead of lingering around.
    ports:
14
      - 6379:6379
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

  # stateful storage
  database:
    image: mysql
    # this containers logging is not really that interesting during development
    logging:
      driver: none
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD:
      MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:-secret}"
      MYSQL_DATABASE: "${DB_NAME:-failmap}"
      MYSQL_USER: "${DB_USER:-failmap}"
      MYSQL_PASSWORD: "${DB_PASSWORD:-failmap}"
    ports:
      - 3306:3306
    # Configure database to persist accross restarts of the development environment.
    volumes:
      - ./dev_db/:/var/lib/mysql/

  # task executer
  worker:
    image: failmap/admin
    build:
      context: .
      dockerfile: "${PWD}/Dockerfile"
    links:
      - broker
      - database:mysql
    # celery dislikes running as root
    user: nobody
    environment:
      BROKER: redis://broker:6379/0
      DJANGO_DATABASE: production
48
      # let celery be a little more informative regarding console messages
49 50
      TERM: xterm-color
      DEBUG: 1
51 52 53 54
    # mount current source into container to allow changes to propagate without container rebuild
    volumes:
      - .:/source/
    # use watchdog to provide auto restart functionality on changed code
55
    entrypoint: [ '/source/tools/autoreload.sh', 'failmap-admin']
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
    command: [ "celery", "worker", "-l", "info", "-c", "6" ]

  # web interface
  admin:
    image: failmap/admin
    build:
      context: .
      dockerfile: "${PWD}/Dockerfile"
    links:
      - broker
      - database:mysql
    environment:
      BROKER: redis://broker:6379/0
      DJANGO_DATABASE: production
      UWSGI_PYTHON_AUTORELOAD: "yes"
71
      # django decides what to log based on type of console
72 73
      TERM: xterm-color
      DEBUG: 1
74 75
      # disable server static files from collectstatic during development, passthrough to django staticfiles urlpatterns
      UWSGI_STATIC_MAP:
76 77 78 79
    # mount current source into container to allow changes to propagate without container rebuild
    volumes:
      - .:/source/
    ports:
80
      - 8000:8000
81 82
    # use watchdog to provide auto restart functionality on changed code
    entrypoint: [ '/source/tools/autoreload.sh', 'failmap-admin']
83 84
    command: [ "runuwsgi" ]

85
  # migrate
86 87 88 89 90 91 92
  migrate:
    image: failmap/admin
    build:
      context: .
      dockerfile: "${PWD}/Dockerfile"
    links:
      - database:mysql
93 94
    volumes:
      - .:/source/
95 96
    environment:
      DJANGO_DATABASE: production
97
      # django decides what to log based on type of console
98
      TERM: xterm-color
99
    command: [ "migrate" ]
100 101
    # retry if action failes (ie: database container is not ready yet)
    restart: on-failure
102 103 104 105 106 107 108 109

  loaddata:
    image: failmap/admin
    build:
      context: .
      dockerfile: "${PWD}/Dockerfile"
    links:
      - database:mysql
110 111
    volumes:
      - .:/source/
112 113
    environment:
      DJANGO_DATABASE: production
114
      # django decides what to log based on type of console
115
      TERM: xterm-color
116
    command: [ "load-dataset", "development", "testdata" ]
117 118
    # retry if action failes (ie: database container is not ready yet)
    restart: on-failure
119 120 121 122 123 124 125 126 127 128

  flower:
    image: failmap/admin
    build:
      context: .
      dockerfile: "${PWD}/Dockerfile"
    links:
      - broker
    environment:
      BROKER: redis://broker:6379/0
129
      TERM: xterm-color
130 131 132
    ports:
      - 5555:5555
    command: [ "celery", "flower" ]