2019-02-17 20:53:04 +01:00
---
date: "2019-02-12:00:00+02:00"
title: "Full docker example"
draft: false
type: "doc"
menu:
sidebar:
parent: "setup"
---
# Full docker example
This docker compose configuration will run Vikunja with backend and frontend with a mariadb as database.
2019-11-25 19:07:11 +01:00
It uses an nginx container or traefik on the host to proxy backend and frontend into a single port.
For all available configuration options, see [configuration ]({{< ref "config.md">}} ).
2020-07-06 21:53:26 +02:00
< div class = "notification is-warning" >
< b > NOTE:< / b > If you intend to run Vikunja with mysql and/or to use non-latin characters
< a href = "{{< ref " utf-8 . md " > }}">make sure your db is utf-8 compatible< / a > .< br / >
All examples on this page already reflect this and do not require additional work.
< / div >
2020-09-03 17:34:44 +02:00
{{< table_of_contents > }}
## Redis
2019-11-25 19:07:11 +01:00
2020-05-11 22:02:15 +02:00
To use redis, you'll need to add this to the config examples below:
{{< 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
2020-05-22 21:18:11 +02:00
volumes:
- ./files:/app/vikunja/files
2020-05-11 22:02:15 +02:00
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/ ).
2019-11-25 19:07:11 +01:00
2020-05-11 22:02:15 +02:00
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`
2019-11-25 19:07:11 +01:00
{{< highlight yaml > }}
version: '3'
services:
api:
image: vikunja/api
environment:
VIKUNJA_DATABASE_HOST: db
VIKUNJA_DATABASE_PASSWORD: supersecret
VIKUNJA_DATABASE_TYPE: mysql
VIKUNJA_DATABASE_USER: vikunja
VIKUNJA_DATABASE_DATABASE: vikunja
2019-11-25 19:08:24 +01:00
volumes:
- ./files:/app/vikunja/files
2019-11-25 19:07:11 +01:00
networks:
- web
- default
depends_on:
- db
restart: unless-stopped
labels:
- "traefik.enable=true"
2020-08-20 14:08:35 +02:00
- "traefik.http.routers.vikunja-api.rule=Host(`vikunja.example.com`) && PathPrefix(`/api/v1`, `/dav/` , `/.well-known/` )"
2020-05-11 22:02:15 +02:00
- "traefik.http.routers.vikunja-api.entrypoints=https"
- "traefik.http.routers.vikunja-api.tls.certResolver=acme"
2019-11-25 19:07:11 +01:00
frontend:
image: vikunja/frontend
labels:
- "traefik.enable=true"
2020-05-11 22:02:15 +02:00
- "traefik.http.routers.vikunja-frontend.rule=Host(`vikunja.example.com`)"
- "traefik.http.routers.vikunja-frontend.entrypoints=https"
- "traefik.http.routers.vikunja-frontend.tls.certResolver=acme"
2019-11-25 19:07:11 +01:00
networks:
- web
- default
restart: unless-stopped
db:
image: mariadb:10
2020-07-06 21:53:26 +02:00
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
2019-11-25 19:07:11 +01:00
environment:
MYSQL_ROOT_PASSWORD: supersupersecret
MYSQL_USER: vikunja
MYSQL_PASSWORD: supersecret
MYSQL_DATABASE: vikunja
volumes:
- ./db:/var/lib/mysql
restart: unless-stopped
command: --max-connections=1000
networks:
web:
external: true
{{< / highlight > }}
2020-05-11 22:02:15 +02:00
## 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/ ).
2019-11-25 19:07:11 +01:00
{{< highlight yaml > }}
version: '3'
services:
api:
image: vikunja/api
environment:
VIKUNJA_DATABASE_HOST: db
VIKUNJA_DATABASE_PASSWORD: supersecret
VIKUNJA_DATABASE_TYPE: mysql
VIKUNJA_DATABASE_USER: vikunja
VIKUNJA_DATABASE_DATABASE: vikunja
2019-11-25 19:08:24 +01:00
volumes:
- ./files:/app/vikunja/files
2019-11-25 19:07:11 +01:00
networks:
- web
- default
depends_on:
- db
restart: unless-stopped
labels:
- "traefik.docker.network=web"
- "traefik.enable=true"
2020-08-20 14:08:35 +02:00
- "traefik.frontend.rule=Host:vikunja.example.com;PathPrefix:/api/v1,/dav/,/.well-known"
2019-11-25 19:07:11 +01:00
- "traefik.port=3456"
- "traefik.protocol=http"
frontend:
image: vikunja/frontend
labels:
- "traefik.docker.network=web"
- "traefik.enable=true"
- "traefik.frontend.rule=Host:vikunja.example.com;PathPrefix:/"
- "traefik.port=80"
- "traefik.protocol=http"
networks:
- web
- default
restart: unless-stopped
db:
image: mariadb:10
2020-07-06 21:53:26 +02:00
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
2019-11-25 19:07:11 +01:00
environment:
MYSQL_ROOT_PASSWORD: supersupersecret
MYSQL_USER: vikunja
MYSQL_PASSWORD: supersecret
MYSQL_DATABASE: vikunja
volumes:
- ./db:/var/lib/mysql
restart: unless-stopped
command: --max-connections=1000
networks:
web:
external: true
{{< / highlight > }}
## Example with nginx as proxy
2019-02-17 20:53:04 +01:00
You'll need to save this nginx configuration on your host under `nginx.conf`
(or elsewhere, but then you'd need to adjust the proxy mount at the bottom of the compose file):
{{< highlight conf > }}
server {
listen 80;
location / {
proxy_pass http://frontend:80;
}
2020-08-20 14:08:35 +02:00
location ~* ^/(api|dav|\.well-known)/ {
2019-02-17 20:53:04 +01:00
proxy_pass http://api:3456;
2020-08-17 22:15:48 +02:00
client_max_body_size 20M;
2019-02-17 20:53:04 +01:00
}
}
{{< / highlight > }}
2020-08-17 22:15:48 +02:00
< div class = "notification is-warning" >
< b > NOTE:< / b > If you change the max upload size in Vikunja's settings, you'll need to also change the < code > client_max_body_size< / code > in the nginx proxy config.
< / div >
2020-05-11 22:02:15 +02:00
`docker-compose.yml` config:
2019-02-17 20:53:04 +01:00
{{< highlight yaml > }}
version: '3'
services:
db:
image: mariadb:10
2020-07-06 21:53:26 +02:00
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
2019-02-17 20:53:04 +01:00
environment:
MYSQL_ROOT_PASSWORD: supersecret
MYSQL_DATABASE: vikunja
volumes:
- ./db:/var/lib/mysql
2020-05-23 19:34:44 +02:00
restart: unless-stopped
2019-02-17 20:53:04 +01:00
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
2019-11-25 19:08:24 +01:00
volumes:
- ./files:/app/vikunja/files
2019-02-17 20:53:04 +01:00
depends_on:
- db
2020-05-23 19:34:44 +02:00
restart: unless-stopped
2019-02-17 20:53:04 +01:00
frontend:
image: vikunja/frontend
2020-05-23 19:34:44 +02:00
restart: unless-stopped
2019-02-17 20:53:04 +01:00
proxy:
image: nginx
ports:
- 80:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- api
- frontend
2020-05-23 19:34:44 +02:00
restart: unless-stopped
2019-02-17 20:53:04 +01:00
{{< / highlight > }}
2020-06-22 06:48:00 +02:00
## Example with Caddy v2 as proxy
You will need the following `Caddyfile` on your host (or elsewhere, but then you'd need to adjust the proxy mount at the bottom of the compose file):
{{< highlight conf > }}
vikunja.example.com {
reverse_proxy /api/* api:3456
2020-08-20 14:08:35 +02:00
reverse_proxy /.well-known/* api:3456
reverse_proxy /dav/* api:3456
2020-06-22 06:48:00 +02:00
reverse_proxy frontend:80
}
{{< / highlight > }}
`docker-compose.yml` config:
{{< highlight yaml > }}
version: '3'
services:
db:
image: mariadb:10
2020-07-06 21:53:26 +02:00
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
2020-06-22 06:48:00 +02:00
environment:
MYSQL_ROOT_PASSWORD: supersecret
MYSQL_DATABASE: vikunja
volumes:
- ./db:/var/lib/mysql
restart: unless-stopped
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
volumes:
- ./files:/app/vikunja/files
depends_on:
- db
restart: unless-stopped
frontend:
image: vikunja/frontend
restart: unless-stopped
caddy:
image: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
depends_on:
- api
- frontend
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
{{< / highlight > }}