dallinger/docker/ssh_templates/docker-compose-experiment.yml.j2
services:
redis_{{ experiment_id }}:
image: redis
command: redis-server --appendonly yes
volumes:
- dallinger_{{ experiment_id }}_redis_data:/data
healthcheck:
test: "[ $$(redis-cli ping) = 'PONG' ]"
interval: 2s
timeout: 1s
networks:
- dallinger
web:
image: {{ experiment_image }}
user: "${UID}:${GID}"
command: dallinger_heroku_web
depends_on: &commondepends
redis_{{ experiment_id }}:
condition: service_healthy
pgbouncer:
condition: service_started
environment: &commonenv
REDIS_URL: redis://redis_{{ experiment_id }}:6379
DATABASE_URL: postgresql://{{ experiment_id }}:{{ postgresql_password }}@{{ experiment_id }}_pgbouncer/{{ experiment_id }}
HOME: /tmp
HOST: 0.0.0.0
PORT: 5000
{%- for key, value in config.items() %}
{{ key }}: {{ value | string() | tojson }}
{%- endfor %}
networks:
dallinger:
aliases:
- {{ experiment_id }}_web
volumes:
- ${HOME}/dallinger-data/{{ experiment_id }}:/var/lib/dallinger
{%- if docker_volumes | length > 0 %}
{%- for volume in docker_volumes.split(",") %}
- {{ volume | string() }}
{%- endfor %}
{%- endif %}
{% set num_dynos = config["num_dynos_worker"] | default('1') | int %}
{%- for number in range(num_dynos) %}
worker_{{ number + 1 }}:
image: {{ experiment_image }}
command: dallinger_heroku_worker
depends_on:
<<: *commondepends
user: "${UID}:${GID}"
environment:
<<: *commonenv
networks:
- dallinger
volumes:
- ${HOME}/dallinger-data/{{ experiment_id }}:/var/lib/dallinger
{%- if docker_volumes | length > 0 %}
{%- for volume in docker_volumes.split(",") %}
- {{ volume | string() }}
{%- endfor %}
{%- endif %}
{%- endfor %}
pgbouncer:
image: docker.io/bitnami/pgbouncer:1.19.1
container_name: {{ experiment_id }}_pgbouncer
networks:
dallinger:
environment:
- POSTGRESQL_HOST=postgresql
- PGBOUNCER_AUTH_TYPE=md5
- PGBOUNCER_SET_DATABASE_USER=yes
- PGBOUNCER_SET_DATABASE_PASSWORD=yes
- POSTGRESQL_USERNAME={{ experiment_id }}
- POSTGRESQL_PASSWORD={{ postgresql_password }}
- PGBOUNCER_PORT=5432
- PGBOUNCER_DATABASE={{ experiment_id }}
- PGBOUNCER_POOL_MODE=transaction
# Connections to postgres will be closed after 60 seconds of inactivity
- PGBOUNCER_SERVER_IDLE_TIMEOUT=60
{%- if config["clock_on"] %}
clock:
image: {{ experiment_image }}
user: "${UID}:${GID}"
command: dallinger_heroku_clock
depends_on:
<<: *commondepends
environment:
<<: *commonenv
PORT: 5000
networks:
dallinger:
aliases:
- {{ experiment_id }}_clock
volumes:
- ${HOME}/dallinger-data/{{ experiment_id }}:/var/lib/dallinger
{%- endif %}
volumes:
dallinger_{{ experiment_id }}_redis_data:
networks:
dallinger:
name: dallinger