Automations for my personal docker cloud
The cloud 🙃
flowchart LR
A[laptop]
B((github repo))
subgraph docker_cloud
D[containers]
end
A -- push commits --> B ~~~ docker_cloud -- propagates changes --> C & D
- Why this
- Installation
- Automatic provisioning
- Backup
- Monitoring
- Docker services management
- Add a new service
- Configure web interface
- Adding env variables
- Adding configuration files
- Available roles
The goal of this project is to manage my personal docker cloud in a git ops way with declarative infrastructure and configurations, to achieve this goal the following tech stack is deployed:
- docker to manage services for personal use
- ansible to automate provisioning operations
- git to version the infrastructure state
Installation of the repository is done by cloning it inside the docker cloud and making an initial setup to allow the continuous integration pipeline to trigger itself when commits are made to the main branch
- clone repository inside the docker cloud
git clone https://github.com/carnivuth/labcraft- run the make target to create the vault file, then fill the file with your own secrets
make inventory/group_vars/all/vault.yml- Run the make target to create the install repository
make installThis will create a cronjob that runs git pull every minute and a git hook to run the install target, also the install targets runs a set of playbook to align the cloud
Every time a commit is pushed to remote cron will pull the updates and the git hook will run the install target to align the cloud to the new configuration
---
title: UPDATE WORKFLOW
---
sequenceDiagram
participant dev_machine
participant github_repo
participant docker_cloud
dev_machine ->> github_repo: push chainges
loop every x minutes
docker_cloud ->> github_repo: fetch changes
alt changes
docker_cloud ->> docker_cloud: run middleware
docker_cloud ->> docker_cloud: run workflow based on the file that was modified
end
end
TODO
TODO
The project is used to manage my personal cloud services using docker containers
flowchart TD
subgraph docker host
A((service 1))
B((service 2))
C((service 3))
D[traefik]
E[authelia]
F[grafana]
G[prometheus]
end
D --exposes--> A & B & C
D -- delegates auth --> E
G -- scrapes metrics --> A & B & C
F -- visualizes metrics --> G
Services are installed using a playbook and docker compose configuration file, to add a service run the following make target
SERVICE_NAME=my service
make playbooks/roles/align_services/$SERVICE_NAMETo configure web interface, add the service network
networks:
services:
name: services
external: trueThen add traefik and homepage labels for reverse proxy configuration and homepage icon (replace service with the service name)
labels:
- "traefik.enable=true"
- "traefik.http.routers.service.rule=Host(`${HOST}`)"
- "traefik.http.services.service.loadbalancer.server.port=25600"
- "traefik.http.routers.service.entrypoints=websecure"
- "traefik.http.routers.service.tls=true"
- "traefik.http.routers.service.tls.certresolver=myresolver"
- "homepage.group=service group"
- "homepage.name=Komga"
- "homepage.icon=service.svg"
- "homepage.href=https://${HOST}"
- "homepage.description=Service description"Environment variables can be added in the playbooks/roles/align_services/files/$SERVICE_NAME/env.j2
Configuration files are managed inside the etc/ directory and copied over when provisioning, when adding a service that needs configuration files create a dir etc/ inside the service folder and edit the parameters as needed, see homepage service as reference
