quentincaffeino / svc-traefik

This is a traefik service setup with multi-env docker-compose and make

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Traefik Service

This is a traefik service setup with docker-compose.

Traefik is an open-source Edge Router that makes publishing your services a fun and easy experience. It receives requests on behalf of your system and finds out which components are responsible for handling them.

Web


Table of contents

Variables

  • BASE_DOMAIN - The base domain on which this service would run. For example traefik dashboard could be acessed on http://BASE_DOMAIN.localhost/dashboard/ (By default: http://traefik.localhost/dashboard/). This does not set base domain for services that use traefik.
  • HTTP_PORT & HTTPS_PORT - Ports that traefik would listen to. Defaults to 80 and 443.
  • ACME_EMAIL - You MUST set it in production. This email will be used to register your letsencrypt certificates for services that would run under this traefik service.

Base repo for docker based services with make [extends svc-base-docker]

This setup makes use of docker-compose ability to combine multiple configurations by reading several input files via defining multiple -f attributes and also combines it with environment-based make to make use easier with multi-environment setups with dynamic variables and env-based docker-compose configs

Variables [extends svc-base-docker]

  • PROJECT_NAME - Project name
  • DOCKER_COMPOSE_FILES - Instructs make which docker-compose files use for which environment

Prerequisites [extends svc-base-docker]

  • sh
  • make
  • perl
  • docker
  • docker compose (or docker-compose, supports both)

Usage [extends svc-base-docker]

Every docker-compose comand is wrapped with make. Example usage:

[VARIABLES] make docker-[COMMAND-NAME] [VARIABLES]
# Eg.:
make docker-up
ENV=prod make docker-config
make docker-build s="service-name"

Where COMMAND-NAME is a docker-compose command name (eg.: up, down, config, ...)

Compose options [extends svc-base-docker]

There are times when you need to pass extra variables to docker-compose command. Most of them accept some sort of options flags/attributes. Those could be passed using go (global options for docker-compose) or o (options for docker-compose command) variable like so:

make docker-up go=--verbose o="-d"
Note: Quotes are only nessesary when there are multiple space-separated flags/attrs to pass to the command.

Some commands also accept service(s) which to run command against (eg.: build to build only specific services). To pass those use s option:

make docker-build s="service-name service2-name"

Extra commands [extends svc-base-docker]

Some commands with options are very commonly used and because to write them each time is very inconvenient shortcuts were added:

make docker-upd
# is same as
make docker-up o="--detach" # Detached mode: Run containers in the background.

# AND

make docker-rmf
# is same as
make docker-rm o="--force" # Don't ask to confirm removal

# AND

make docker-logsf
# is same as
make docker-logs o="--follow" # View and follow output from containers

Base repo for services with make [extends svc-base-make]

Make setup which makes use of per-environment dotenv files

Prerequisites [extends svc-base-make]

  • sh
  • make
  • perl

Usage [extends svc-base-make]

make help

dotenv [extends svc-base-make]

Using make and per-environment dotenv files it is prepaired to run on several environments.

Overrides [extends svc-base-make]

To override variables locally create .env.local or .env.ENVIRONMENT-NAME.local (eg.: .env.prod.local) files.

About

This is a traefik service setup with multi-env docker-compose and make

License:MIT License


Languages

Language:Makefile 93.7%Language:Shell 6.3%