build-configs/templates/php/drupal/docker-compose.yaml.twig
Oliver Davies 605849cb80 Rename the proxy network to proxy
This makes its intent clearer and avoids confusion with the `web`
service.
2024-05-10 23:57:44 +02:00

91 lines
2.1 KiB
Twig

# {{ managedText|raw }}
x-proxy: &default-proxy
networks:
- default
- proxy
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik_proxy"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(
`${COMPOSE_PROJECT_NAME}.docker.localhost`,
{% for host in web.extra_hosts | default([]) -%}
{{ '`' ~ host ~ '`,' }}
{%- endfor %}
)"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.tls=true"
x-app: &default-app
volumes:
- "${DOCKER_WEB_VOLUME:-./{{ drupal.docroot }}:{{ project_root }}/{{ drupal.docroot }}}"
env_file:
- .env
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
networks:
- default
deploy:
resources:
limits:
cpus: "${DOCKER_MYSQL_CPUS:-0}"
memory: "${DOCKER_MYSQL_MEMORY:-0}"
labels:
- "traefik.enable=false"
tty: true
services:
{% if "web" in dockerCompose.services %}
web:
<<: [*default-proxy, *default-app]
build:
context: .
target: web
depends_on:
- php
profiles: [web]
{% endif %}
{% set anchors = [
"apache" in php.version ? "*default-proxy" : null,
"*default-app",
] -%}
php:
<<: [{{ anchors | filter(item => item is not null) | join(", ") }}]
build:
context: .
target: build
args:
- "DOCKER_UID=${DOCKER_UID:-1000}"
volumes:
- .:{{ project_root }}
{% if "database" in dockerCompose.services -%}
depends_on:
- database
{% endif -%}
profiles: [php]
database:
image: {{ database.type }}:{{ database.version }}
deploy:
resources:
limits:
cpus: "${DOCKER_MYSQL_CPUS:-0}"
memory: "${DOCKER_MYSQL_MEMORY:-0}"
volumes:
- db-data:/var/lib/mysql
{{ database.extra_databases is not empty ? '- ./tools/docker/images/database/root/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d' : '' }}
env_file:
- .env
labels:
- "traefik.enable=false"
environment:
MYSQL_RANDOM_ROOT_PASSWORD: true
profiles: [database]
volumes:
db-data: {}
networks:
proxy:
external: true
name: traefik_proxy