Add traefik 2 example configuration

This commit is contained in:
kolaente 2020-05-11 22:02:15 +02:00
parent 55cd40d175
commit e43e601912
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -15,11 +15,34 @@ It uses an nginx container or traefik on the host to proxy backend and frontend
For all available configuration options, see [configuration]({{< ref "config.md">}}). For all available configuration options, see [configuration]({{< ref "config.md">}}).
## Example with traefik ### Redis
This example assumes [traefik](https://traefik.io) in version 1 installed and configured to [use docker as a configuration provider](https://docs.traefik.io/v1.7/configuration/backends/docker/). To use redis, you'll need to add this to the config examples below:
### Without redis {{< highlight yaml >}}
version: '3'
services:
api:
image: vikunja/api
environment:
VIKUNJA_REDIS_ENABLED: 1
VIKUNJA_REDIS_HOST: 'redis:6379'
VIKUNJA_CACHE_ENABLED: 1
VIKUNJA_CACHE_TYPE: redis
redis:
image: redis
{{< /highlight >}}
## Example with traefik 2
This example assumes [traefik](https://traefik.io) version 2 installed and configured to [use docker as a configuration provider](https://docs.traefik.io/providers/docker/).
We also make a few assumtions here which you'll most likely need to adjust for your traefik setup:
* Your domain is `vikunja.example.com`
* The entrypoint you want to make vikunja available from is called `https`
* The tls cert resolver is called `acme`
{{< highlight yaml >}} {{< highlight yaml >}}
version: '3' version: '3'
@ -42,19 +65,17 @@ services:
- db - db
restart: unless-stopped restart: unless-stopped
labels: labels:
- "traefik.docker.network=web"
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.frontend.rule=Host:vikunja.example.com;PathPrefix:/api/v1" - "traefik.http.routers.vikunja-api.rule=Host(`vikunja.example.com`) && PathPrefix(`/api/v1`)"
- "traefik.port=3456" - "traefik.http.routers.vikunja-api.entrypoints=https"
- "traefik.protocol=http" - "traefik.http.routers.vikunja-api.tls.certResolver=acme"
frontend: frontend:
image: vikunja/frontend image: vikunja/frontend
labels: labels:
- "traefik.docker.network=web"
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.frontend.rule=Host:vikunja.example.com;PathPrefix:/" - "traefik.http.routers.vikunja-frontend.rule=Host(`vikunja.example.com`)"
- "traefik.port=80" - "traefik.http.routers.vikunja-frontend.entrypoints=https"
- "traefik.protocol=http" - "traefik.http.routers.vikunja-frontend.tls.certResolver=acme"
networks: networks:
- web - web
- default - default
@ -76,7 +97,9 @@ networks:
external: true external: true
{{< /highlight >}} {{< /highlight >}}
### With redis ## Example with traefik 1
This example assumes [traefik](https://traefik.io) in version 1 installed and configured to [use docker as a configuration provider](https://docs.traefik.io/v1.7/configuration/backends/docker/).
{{< highlight yaml >}} {{< highlight yaml >}}
version: '3' version: '3'
@ -90,10 +113,6 @@ services:
VIKUNJA_DATABASE_TYPE: mysql VIKUNJA_DATABASE_TYPE: mysql
VIKUNJA_DATABASE_USER: vikunja VIKUNJA_DATABASE_USER: vikunja
VIKUNJA_DATABASE_DATABASE: vikunja VIKUNJA_DATABASE_DATABASE: vikunja
VIKUNJA_REDIS_ENABLED: 1
VIKUNJA_REDIS_HOST: 'redis:6379'
VIKUNJA_CACHE_ENABLED: 1
VIKUNJA_CACHE_TYPE: redis
volumes: volumes:
- ./files:/app/vikunja/files - ./files:/app/vikunja/files
networks: networks:
@ -101,7 +120,6 @@ services:
- default - default
depends_on: depends_on:
- db - db
- redis
restart: unless-stopped restart: unless-stopped
labels: labels:
- "traefik.docker.network=web" - "traefik.docker.network=web"
@ -132,8 +150,6 @@ services:
- ./db:/var/lib/mysql - ./db:/var/lib/mysql
restart: unless-stopped restart: unless-stopped
command: --max-connections=1000 command: --max-connections=1000
redis:
image: redis
networks: networks:
web: web:
@ -159,7 +175,7 @@ server {
} }
{{< /highlight >}} {{< /highlight >}}
### Without redis `docker-compose.yml` config:
{{< highlight yaml >}} {{< highlight yaml >}}
version: '3' version: '3'
@ -196,48 +212,3 @@ services:
- api - api
- frontend - frontend
{{< /highlight >}} {{< /highlight >}}
### With redis
{{< highlight yaml >}}
version: '3'
services:
db:
image: mariadb:10
environment:
MYSQL_ROOT_PASSWORD: supersecret
MYSQL_DATABASE: vikunja
volumes:
- ./db:/var/lib/mysql
redis:
image: redis
api:
image: vikunja/api
environment:
VIKUNJA_DATABASE_HOST: db
VIKUNJA_DATABASE_PASSWORD: supersecret
VIKUNJA_DATABASE_TYPE: mysql
VIKUNJA_DATABASE_USER: root
VIKUNJA_DATABASE_DATABASE: vikunja
VIKUNJA_REDIS_ENABLED: 1
VIKUNJA_REDIS_HOST: 'redis:6379'
VIKUNJA_CACHE_ENABLED: 1
VIKUNJA_CACHE_TYPE: redis
volumes:
- ./files:/app/vikunja/files
depends_on:
- db
- redis
frontend:
image: vikunja/frontend
proxy:
image: nginx
ports:
- 80:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- api
- frontend
{{< /highlight >}}