# Bring up all the pieces necessary to run the workbench # Data persists in Docker volumes and in local dir # This file passes through all necessary env variables to requisite # Docker containers and makes them available when running commands via # `docker exec`. version: '3.4' services: database: image: postgres:10.4 environment: POSTGRES_USER: cjworkbench POSTGRES_PASSWORD: cjworkbench POSTGRES_DB: cjworkbench PGDATA: /var/lib/postgresql/data/10.4 networks: [ 'dev' ] volumes: - dbdata:/var/lib/postgresql/data rabbitmq: image: rabbitmq:3.7.8-management ports: [ '15672' ] # open management port, for debugging networks: [ 'dev' ] environment: # Use just one CPU RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: '+S 1:1 +stbt ts +A 12' minio: image: minio/minio:RELEASE.2019-05-02T19-07-09Z networks: [ 'dev' ] ports: [ '8001:9000' ] environment: MINIO_ACCESS_KEY: minio_access MINIO_SECRET_KEY: minio_secret volumes: - minio_data:/data command: [ 'server', '/data' ] webpack: build: context: . target: jsbase volumes: # Migrate - type: bind source: ./ target: /app/ consistency: cached - node_modules:/app/node_modules:rw - jest_cache:/tmp/jest_0:rw networks: [ 'dev' ] command: [ 'node_modules/.bin/webpack', '--mode', 'development', '--watch' ] frontend: build: context: . target: pydev volumes: - type: bind source: ./ target: /app/ consistency: cached - virtualenvs:/root/.local/share/virtualenvs/:rw environment: PYTHONUNBUFFERED: '1' ASGI_THREADS: '5' CJW_DB_HOST: database CJW_RABBITMQ_HOST: amqp://guest:guest@rabbitmq/ CJW_DB_PASSWORD: cjworkbench CJW_SECRET_KEY: cjw-secret-key MINIO_ACCESS_KEY: minio_access MINIO_SECRET_KEY: minio_secret MINIO_URL: http://minio:9000 MINIO_EXTERNAL_URL: http://localhost:8001 MINIO_BUCKET_PREFIX: dev ports: [ '8000:8000', '35729:35729' ] networks: [ 'dev' ] depends_on: [ 'database', 'rabbitmq', 'minio' ] command: [ # Use http-process-proxy, not Django reload. Django reload crashes # when there's a syntax error. 'pipenv', 'run', 'python', '-m', 'httpprocessproxy', '0.0.0.0:8000', '0.0.0.0:8080', '--exclude', '**/*.pyc', '**/tests/**/*', '--pattern', 'server/**/*.py', 'server/**/*.json', 'server/**/*.yaml', 'server/lessons/**/*.html', 'server/courses/**/*.html', 'cjworkbench/**/*.py', '--exec', 'python', './manage.py', 'runserver', '--noreload', '--insecure', '0.0.0.0:8080' ] worker: # It'd be nice to use YAML anchors to copy these parameters ... but # PyCharm's YAML parser seems to die when we use YAML anchors. build: context: . target: pydev volumes: - type: bind source: ./ target: /app/ consistency: cached - virtualenvs:/root/.local/share/virtualenvs/:rw environment: PYTHONUNBUFFERED: '1' ASGI_THREADS: '5' CJW_DB_HOST: database CJW_RABBITMQ_HOST: amqp://guest:guest@rabbitmq/ CJW_DB_PASSWORD: cjworkbench CJW_SECRET_KEY: cjw-secret-key MINIO_ACCESS_KEY: minio_access MINIO_SECRET_KEY: minio_secret MINIO_URL: http://minio:9000 MINIO_BUCKET_PREFIX: dev depends_on: [ 'database', 'rabbitmq', 'minio' ] networks: [ 'dev' ] command: [ # Use socat so worker can fetch URLs like http://localhost:8000/static/lessons/a-lesson/file.csv # Use watchman, not Django autoreload. autoreload crashes when there's a # syntax error. 'sh', '-c', 'socat -d TCP-LISTEN:8000,reuseaddr,fork TCP:frontend:8000 & pipenv run bin/watchman-monitor --exclude "**/*.pyc" "**/tests/**/*" --pattern "cjworkbench/**/*.py" "worker/**/*.py" "server/modules/**/*.*" --exec python ./manage.py worker' ] cron: # It'd be nice to use YAML anchors to copy these parameters ... but # PyCharm's YAML parser seems to die when we use YAML anchors. build: context: . target: pydev volumes: - type: bind source: ./ target: /app/ consistency: cached - virtualenvs:/root/.local/share/virtualenvs/:rw environment: PYTHONUNBUFFERED: '1' ASGI_THREADS: '5' CJW_DB_HOST: database CJW_RABBITMQ_HOST: amqp://guest:guest@rabbitmq/ CJW_DB_PASSWORD: cjworkbench CJW_SECRET_KEY: cjw-secret-key MINIO_ACCESS_KEY: minio_access MINIO_SECRET_KEY: minio_secret MINIO_URL: http://minio:9000 MINIO_BUCKET_PREFIX: dev depends_on: [ 'database', 'rabbitmq', 'minio' ] networks: [ 'dev' ] command: [ # Use watchman, not Django autoreload. autoreload crashes when there's a # syntax error. 'pipenv', 'run', 'bin/watchman-monitor', '--exclude', '**/*.pyc', '**/tests/**/*', '--pattern', 'cjworkbench/**/*.py', 'server/cron/**/*.py', 'server/management/commands/cron.py', '--exec', 'python', './manage.py', 'cron' ] testdatabase: image: postgres:10.4 environment: POSTGRES_USER: cjworkbench POSTGRES_PASSWORD: cjworkbench POSTGRES_DB: cjworkbench PGDATA: /var/lib/postgresql/data/10.4 networks: [ 'test' ] volumes: - type: tmpfs target: /var/lib/postgresql/data command: [ '-c', 'wal_level=minimal', '-c', 'max_wal_senders=0', '-c', 'fsync=off', '-c', 'synchronous_commit=off', '-c', 'full_page_writes=off' ] testrabbitmq: image: rabbitmq:3.7.8 networks: [ 'test' ] volumes: - type: tmpfs target: /var/lib/rabbitmq environment: # Use just one CPU RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: '+S 1:1 +stbt ts +A 12' testminio: image: minio/minio:RELEASE.2019-05-02T19-07-09Z networks: [ 'test' ] volumes: - type: tmpfs target: /data environment: MINIO_ACCESS_KEY: minio_access MINIO_SECRET_KEY: minio_secret command: server /data networks: dev: {} test: {} volumes: dbdata: {} minio_data: {} virtualenvs: {} # Let's not make node_modules a bind mount: Windows bind mounts seem # to behave a bit differently from Linux bind mounts. Use a Docker volume # instead. node_modules: {} jest_cache: {}