mirror of
https://github.com/opdavies/build-configs.git
synced 2025-01-23 10:37:31 +00:00
Oliver Davies
4d034d9ba2
Allow for declaring extra databases that should be created when the project is first started. This is done by adding an `extra_databases` key to `database`, containing a list of database names. ```yaml database: type: mariadb version: 10 extra_databases: - tinhat - freshcover ```
101 lines
2.4 KiB
Twig
101 lines
2.4 KiB
Twig
# {{ managedText | raw }}
|
|
|
|
x-proxy: &default-proxy
|
|
networks:
|
|
- default
|
|
- web
|
|
labels:
|
|
- "traefik.docker.network=traefik_proxy"
|
|
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(
|
|
`${COMPOSE_PROJECT_NAME}.localhost`,
|
|
{% for host in web.extra_hosts | default([]) -%}
|
|
{{ '`' ~ host ~ '`,' }}
|
|
{%- endfor %}
|
|
)"
|
|
|
|
x-app: &default-app
|
|
volumes:
|
|
- "${DOCKER_WEB_VOLUME:-./{{ "drupal-project" == type ? drupal.docroot : '' }}:{{ project_root }}{{ "drupal-project" == type ? '/' ~ 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.enabled=false"
|
|
tty: true
|
|
|
|
services:
|
|
{% if dockerCompose.services.web is not defined or dockerCompose.services.web != false -%}
|
|
web:
|
|
<<: [*default-proxy, *default-app]
|
|
build:
|
|
context: .
|
|
target: web
|
|
depends_on:
|
|
- php
|
|
profiles: [web]
|
|
{% endif %}
|
|
|
|
{% if "php" == language %}
|
|
php:
|
|
<<: *default-app
|
|
build:
|
|
context: .
|
|
target: build
|
|
args:
|
|
- "DOCKER_UID=${DOCKER_UID:-1000}"
|
|
volumes:
|
|
- .:{{ project_root }}
|
|
{% if "database" in dockerCompose.services|keys -%}
|
|
depends_on:
|
|
- database
|
|
{% endif -%}
|
|
profiles: [php]
|
|
{% elseif "node" == language %}
|
|
node:
|
|
{{ type is same as "fractal" ? "<<: [*default-proxy, *default-app]" : "<<: *default-app" }}
|
|
build:
|
|
context: .
|
|
target: build
|
|
volumes:
|
|
- .:{{ project_root }}
|
|
{% if "database" in dockerCompose.services|keys -%}
|
|
depends_on:
|
|
- database
|
|
{% endif -%}
|
|
profiles: [node]
|
|
{% endif %}
|
|
|
|
{% if "database" in dockerCompose.services|keys %}
|
|
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.enabled=false"
|
|
environment:
|
|
MYSQL_RANDOM_ROOT_PASSWORD: true
|
|
profiles: [database]
|
|
|
|
volumes:
|
|
db-data: {}
|
|
{% endif -%}
|
|
|
|
networks:
|
|
web:
|
|
name: traefik_proxy
|