Skip to content

Example Docker Compose Runtime

Manuele Vaccari edited this page Jul 25, 2020 · 4 revisions

Example production environment using MariaDB and Traefik.

docker-compose.yml

version: "2"
services:
  db:
    image: mariadb
    command:
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
    restart: always
    networks:
      - internal
    volumes:
      - ./database:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      MYSQL_DATABASE: ${DB_DATABASE}

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    restart: always
    depends_on:
      - db
    networks:
      - internal
      - traefik_proxy
    dns:
      - 1.1.1.1
      - 1.0.0.1
    environment:
      UPLOAD_LIMIT: 100M
    labels:
      - traefik.enable=true

      - traefik.http.routers.phpmyadmin_jass0.entrypoints=http
      - traefik.http.routers.phpmyadmin_jass0.rule=Host(`${PHPMYADMIN_DOMAIN}`)
      - traefik.http.routers.phpmyadmin_jass0.middlewares=to_https

      - traefik.http.routers.phpmyadmin_jass.entrypoints=https
      - traefik.http.routers.phpmyadmin_jass.rule=Host(`${PHPMYADMIN_DOMAIN}`)
      - traefik.http.routers.phpmyadmin_jass.tls=true
      - traefik.http.routers.phpmyadmin_jass.tls.certresolver=le

  jass:
    image: d3strukt0r/fhnw-jass-server
    restart: always
    command:
      - --verbose
      - --db-location=mariadb://db:3306/${DB_DATABASE}
      - --db-username=${DB_USERNAME}
      - --db-password=${DB_PASSWORD}
      - --ssl
    depends_on:
      - db
    networks:
      - internal
    ports:
      - 2000:2000

networks:
  internal:
    external: false
  traefik_proxy:
    external: true

.env

DB_USERNAME=
DB_PASSWORD=
DB_DATABASE=

PHPMYADMIN_DOMAIN=

The docker-compose.yml uses to_https, which is setup in the docker-compose.yml of Traefik. Add following to labels:

docker-compose.yml

version: "2"
services:
  traefik:
    ...
    labels:
      ...
      - traefik.http.middlewares.to_https.redirectscheme.scheme=https
      ...
Clone this wiki locally