Added traefik Dockerfile and configuration file.

Updated 'production.yml' to add traefik and remove caddy
Removed caddy Dockerfile and configuration file
This commit is contained in:
Demetris Stavrou 2018-05-22 22:23:51 +03:00
parent 36529326d3
commit 52ed5a5f29
5 changed files with 57 additions and 26 deletions

View File

@ -1,14 +0,0 @@
www.{% raw %}{$DOMAIN_NAME}{% endraw %} {
redir https://{{cookiecutter.domain_name}}
}
{% raw %}{$DOMAIN_NAME}{% endraw %} {
proxy / django:5000 {
header_upstream Host {host}
header_upstream X-Real-IP {remote}
header_upstream X-Forwarded-Proto {scheme}
}
log stdout
errors stdout
gzip
}

View File

@ -1,3 +0,0 @@
FROM abiosoft/caddy:0.10.6
COPY ./compose/production/caddy/Caddyfile /etc/Caddyfile

View File

@ -0,0 +1,2 @@
FROM traefik
COPY ./compose/production/traefik/traefik.toml /etc/traefik

View File

@ -0,0 +1,37 @@
logLevel = "ERROR"
defaultEntryPoints = ["http", "https"]
[web]
# Port for the status page
address = ":7080"
# Entrypoints, http and https
[entryPoints]
# http should be redirected to https
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
# https is the default
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
# Enable ACME (Let's Encrypt): automatic SSL
[acme]
# Email address used for registration
email = "{{ cookiecutter.email }}"
storageFile = "acme.json"
entryPoint = "https"
onDemand = false
OnHostRule = true
# Use a HTTP-01 acme challenge rather than TLS-SNI-01 challenge
[acme.httpChallenge]
entryPoint = "http"
# Enable Docker configuration backend
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "{{cookiecutter.domain_name}}"
watch = true
exposedbydefault = false

View File

@ -3,7 +3,6 @@ version: '2'
volumes: volumes:
postgres_data: {} postgres_data: {}
postgres_backup: {} postgres_backup: {}
caddy: {}
services: services:
django:{% if cookiecutter.use_celery == 'y' %} &django{% endif %} django:{% if cookiecutter.use_celery == 'y' %} &django{% endif %}
@ -18,6 +17,11 @@ services:
- ./.envs/.production/.django - ./.envs/.production/.django
- ./.envs/.production/.postgres - ./.envs/.production/.postgres
command: /gunicorn.sh command: /gunicorn.sh
labels:
- "traefik.enable=true"
- "traefik.backend=django"
- "traefik.frontend.rule={{ cookiecutter.domain_name }}"
- "traefik.port=5000"
postgres: postgres:
build: build:
@ -30,20 +34,21 @@ services:
env_file: env_file:
- ./.envs/.production/.postgres - ./.envs/.production/.postgres
caddy: traefik:
build: build:
context: . context: .
dockerfile: ./compose/production/caddy/Dockerfile dockerfile: ./compose/production/traefik/Dockerfile
image: {{ cookiecutter.project_slug }}_production_caddy image: {{ cookiecutter.project_slug }}_production_traefik
depends_on: depends_on:
- django - django
volumes: volumes:
- caddy:/root/.caddy - /var/run/docker.sock:/var/run/docker.sock:ro
env_file: # - ./traefik/traefik.toml:/etc/traefik/traefik.toml:ro
- ./.envs/.production/.caddy # - ./traefik/acme:/etc/traefik/acme
ports: ports:
- "0.0.0.0:80:80" - "80:80"
- "0.0.0.0:443:443" - "443:443"
- "7080:7080"
redis: redis:
image: redis:3.2 image: redis:3.2
@ -59,6 +64,8 @@ services:
- ./.envs/.production/.django - ./.envs/.production/.django
- ./.envs/.production/.postgres - ./.envs/.production/.postgres
command: /start-celeryworker.sh command: /start-celeryworker.sh
labels:
- "traefik.enable=false"
celerybeat: celerybeat:
<<: *django <<: *django
@ -70,5 +77,7 @@ services:
- ./.envs/.production/.django - ./.envs/.production/.django
- ./.envs/.production/.postgres - ./.envs/.production/.postgres
command: /start-celerybeat.sh command: /start-celerybeat.sh
labels:
- "traefik.enable=false"
{%- endif %} {%- endif %}