Skip to content

Instantly share code, notes, and snippets.

@back-2-95
Last active July 25, 2023 12:15
Show Gist options
  • Save back-2-95/df26f936d242e560c8b4030b7c1d97a7 to your computer and use it in GitHub Desktop.
Save back-2-95/df26f936d242e560c8b4030b7c1d97a7 to your computer and use it in GitHub Desktop.
Lagoon Docker Compose setup
#
# Enviromental values for Makefiles and for Docker Compose
#
# Project specific id/prefix. By default it's the project's foldername
# This if here just for the explanation. Can be left out.
#COMPOSE_PROJECT_NAME=custom
# Local hostname
DRUPAL_HOSTNAME=project.docker.so

Default example on how to setup Lagoon project for Drupal

  • docker-compose.yml includes only the information Lagoon uses
  • docker-compose.override.yml includes information for your local development needs (here Druid's Stonehenge)

Background

  • Lagoon reads information from docker-compose.yml to build Kubernetes environment. It does not actually use Docker Compose but just read yml file for information it needs
#
# These are service overrides for local development
#
x-environment:
&default-environment
# Route that should be used locally
LAGOON_ROUTE: &lagoon-route https://${DRUPAL_HOSTNAME}
# Use value "production" to have the system behave like in production
LAGOON_ENVIRONMENT_TYPE: ${LAGOON_ENVIRONMENT_TYPE:-development}
XDEBUG_ENABLE: ${XDEBUG_ENABLE:-false}
SSMTP_MAILHUB: host.docker.internal:1025
DRUSH_OPTIONS_URI: *lagoon-route
SIMPLETEST_BASE_URL: http://nginx:8080
SIMPLETEST_DB: mysql://drupal:drupal@mariadb:3306/drupal
# druidfi/omen specific
DRUPAL_ROUTES: https://varnish-${DRUPAL_HOSTNAME}
OMEN_TOKEN: kissanpissa
x-volumes:
&default-volumes
# Define all volumes you would like to have real-time mounted into the docker containers
volumes:
- &app-volume .:/app:delegated
- &files-volume files:/app/public/sites/default/files
services:
cli:
container_name: ${COMPOSE_PROJECT_NAME}-cli
volumes:
- *app-volume
- *files-volume
- ssh:/tmp/amazeeio_ssh-agent
environment:
<< : *default-environment
networks:
- internal
nginx:
container_name: ${COMPOSE_PROJECT_NAME}-nginx
labels:
- "traefik.enable=true"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-nginx.entrypoints=https"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-nginx.rule=Host(`${DRUPAL_HOSTNAME}`)"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-nginx.tls=true"
- "traefik.http.services.${COMPOSE_PROJECT_NAME}-nginx.loadbalancer.server.port=8080"
- "traefik.docker.network=stonehenge-network"
<< : *default-volumes
depends_on:
- cli
environment:
LAGOON_ROUTE: *lagoon-route
NGINX_FASTCGI_PASS: ${COMPOSE_PROJECT_NAME}-php
networks:
- internal
- stonehenge-network
php:
container_name: ${COMPOSE_PROJECT_NAME}-php
<< : *default-volumes
depends_on:
- cli
environment:
<< : *default-environment
networks:
- internal
mariadb:
container_name: ${COMPOSE_PROJECT_NAME}-db
ports:
- 3306
networks:
- internal
redis:
container_name: ${COMPOSE_PROJECT_NAME}-redis
environment:
MAXMEMORY: 500mb
networks:
- internal
networks:
internal:
{}
stonehenge-network:
external: true
volumes:
files:
{}
ssh:
name: stonehenge-ssh
external: true
#
# These are services which are build on Lagoon
#
services:
cli:
build:
context: .
dockerfile: Dockerfile
target: cli
labels:
lagoon.type: cli-persistent
lagoon.persistent.name: nginx
lagoon.persistent: /app/public/sites/default/files/
nginx:
build:
context: .
dockerfile: Dockerfile
target: nginx
labels:
lagoon.type: nginx-php-persistent
lagoon.persistent: /app/public/sites/default/files/
php:
build:
context: .
dockerfile: Dockerfile
target: php
labels:
lagoon.type: nginx-php-persistent
lagoon.name: nginx
lagoon.persistent: /app/public/sites/default/files/
mariadb:
image: uselagoon/mariadb-10.11-drupal:latest
labels:
lagoon.type: mariadb
redis:
image: uselagoon/redis-7:latest
labels:
lagoon.type: redis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment