Ansible role for deploying a docker website using port or traefik routing
https://www.docker.com/
- Jinja 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| defaults | ||
| meta | ||
| tasks | ||
| templates | ||
| .gitignore | ||
| CHANGELOG.md | ||
| LICENSE | ||
| README.md | ||
Docker Website
Runs one website container from an image, published on a host port and/or through Traefik. Optionally pulls the image daily and recreates the container when the tag points to a new image.
Variables
| Variable | Default | Description |
|---|---|---|
docker_website_name |
~ |
Required. Compose project, container and unit name ([a-z0-9_-]). |
docker_website_image |
~ |
Required. Image incl. tag. |
docker_website_container_port |
80 |
Port inside the container. |
docker_website_domains |
[] |
Domains served through Traefik (traefik_web, websecure). |
docker_website_traefik_certresolver |
default |
Traefik certificate resolver. |
docker_website_port |
~ |
Host port to publish on. This, the domains, or both. |
docker_website_env |
{} |
Environment variables. |
docker_website_auto_update |
true |
Scheduled docker compose pull + up -d (systemd timer <name>-update). |
docker_website_auto_update_schedule |
*-*-* 04:00:00 |
systemd OnCalendar of that timer, e.g. hourly. |
docker_website_docker_path |
/docker/<name> |
Compose file. |
docker_website_uninstall |
false |
Removes container, timer and compose directory. |
Usage
- hosts: web01
roles:
- role: docker_website
vars:
docker_website_name: website
docker_website_image: ghcr.io/example/site:latest
docker_website_domains: [example.com, www.example.com]
Several websites on one host: include the role once per site with a different docker_website_name.
Updates
Auto-update follows the tag: latest or 1 move with new releases and get picked up on the next timer run; a fixed tag like 1.4.2 never changes. A deploy (Ansible run) also pulls. Run an update by hand with systemctl start <name>-update.
Private registries: log in on the host once (docker login).