Code Monkey home page Code Monkey logo

terraform-docker-traefik's Introduction

Docker Traefik Terraform module

pre-commit

Terraform module which deploys a Docker service on Traefik with zero downtime (red/black).

Usage

module "service" {
  source  = "lifeofguenter/traefik/docker"

  name          = "foobar-service"
  image         = "nginx"
  memory        = 256
  listener_rule = "Host(`foobar.mydomain.com`)"
  revision      = var.build_number

  service_network = docker_network.service.name
  traefik_network = "services"

  certresolver = "basic"

  http_entrypoints = ["web"]
  http_middlewares = ["https_redirect@file"]

  https_entrypoints = ["web_secure"]
  https_middlewares = ["compression@file"]

  environment = {
    VERSION = var.build_number
  }

  healthcheck = {
    command      = ["CMD-SHELL", "wget -q --spider --proxy=off localhost:3000/ || exit 1"]
    retries      = 3
    interval     = 20
    start_period = 60
    timeout      = 5
  }
}

Requirements

Name Version
terraform >= 1.3.0

Providers

Name Version
docker 3.0.2
time 0.11.1

Resources

Name Type
docker_container.main resource
docker_image.main resource
time_sleep.grace resource
docker_registry_image.main data source

Inputs

Name Description Type Default Required
basic_auth_users List of authorized users. list(string) [] no
cert_sans List of SANs for the cert. list(string) [] no
certresolver Name of certificate resolver. string null no
command The command to use to start the container. list(string) [] no
container_port Explicit container port to forward traffic to. number null no
cpu_set A comma-separated list or hyphen-separated range of CPUs a container can use. string null no
cpu_shares CPU shares (relative weight) for the container. number null no
deregistration_delay Amount of seconds to wait for open connections to drain before stopping the container. number 60 no
entrypoint The command to use as the Entrypoint for the container. list(string) [] no
environment The environment variables to pass to a container. map(string) {} no
healthcheck The container health check command and associated configuration parameters for the container.
object({
command = list(string)
interval = optional(number, 30)
timeout = optional(number, 30)
start_period = optional(number, 0)
retries = optional(number, 3)
})
null no
http_entrypoints List of HTTP entrypoints. list(string) [] no
http_middlewares List of HTTP middlewares. list(string) [] no
https_entrypoints List of HTTPS entrypoints. list(string) [] no
https_middlewares List of HTTPS middlewares. list(string) [] no
image The image used to start a container. string n/a yes
labels Additional lables to set. map(string) {} no
listener_rule Sets the routing rule. string n/a yes
memory The amount (in MiB) of memory to present to the container. number n/a yes
mounts List for mounts to be added to containers created as part of the service.
list(object({
type = string
target = string
source = optional(string, null)
read_only = optional(bool, false)
}))
[] no
name The name of the service. string n/a yes
publish List of ports to publish.
list(object({
internal = number
external = number
ip = optional(string, null)
protocol = optional(string, "tcp")
}))
[] no
revision Revision number of this service. number n/a yes
service_network Name of the service docker network. string null no
traefik_network Name of the Traefik docker network. string null no
volumes List for mounting volumes in the container.
list(object({
container_path = optional(string, null)
from_container = optional(string, null)
host_path = optional(string, null)
read_only = optional(bool, false)
volume_name = optional(string, null)
}))
[] no

Outputs

Name Description
docker_image_id The ID of the image.
docker_image_name The name of the Docker image.

Contribute

Setup

Mac

$ brew install pre-commit terraform-docs

Linux

$ pip install --user pre-commit
$ ver="$(curl -sSLf https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | jq -r '.tag_name')"; \
  curl -sSLO \
  "https://terraform-docs.io/dl/${ver}/terraform-docs-${ver}-$(uname)-amd64.tar.gz" && \
  tar xf terraform-docs*.tar.gz && \
  chmod +x terraform-docs && \
  sudo mv terraform-docs /usr/local/bin/

Pre-commit

Run once in this directory:

$ pre-commit install

Optionally you can trigger the hooks before committing:

$ pre-commit run -a

terraform-docker-traefik's People

Contributors

dependabot[bot] avatar lifeofguenter avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.