mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Optimized and refactored portfolio for flock.town
This commit is contained in:
50
roles/docker-repository-setup/README.md
Normal file
50
roles/docker-repository-setup/README.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Docker Repository Setup 🚀
|
||||
|
||||
This Ansible role sets up and manages your Docker repository. It ensures that the repository is pulled from your remote Git source, and it automatically triggers a rebuild of your Docker images using Docker Compose.
|
||||
|
||||
## Features 🔧
|
||||
|
||||
- **Default Path Setup:**
|
||||
Automatically sets a default `docker_repository_path` if not already defined.
|
||||
|
||||
- **Repository Management:**
|
||||
Clones or updates your Docker repository from a specified Git repository.
|
||||
|
||||
- **Automated Build Trigger:**
|
||||
Notifies handlers to rebuild the Docker repository using Docker Compose with extended timeouts.
|
||||
|
||||
## Role Structure 📂
|
||||
|
||||
- **Handlers:**
|
||||
- `rebuild docker repository`: Runs `docker compose build` in the designated repository directory with custom timeout settings.
|
||||
|
||||
- **Tasks:**
|
||||
- Sets the default repository path if undefined.
|
||||
- Pulls the latest code from the Docker repository.
|
||||
- Notifies the Docker Compose project setup and triggers a repository rebuild.
|
||||
|
||||
- **Meta:**
|
||||
- Declares a dependency on the `docker-compose` role to ensure that handlers and related dependencies are loaded.
|
||||
|
||||
## Usage ⚙️
|
||||
|
||||
Ensure that you have set the following variables (either via your inventory, `group_vars`, or `host_vars`):
|
||||
|
||||
- `docker_repository_address`: The Git repository URL of your Docker repository.
|
||||
- `docker_compose.directories.services`: The base directory where your Docker services are stored.
|
||||
The role will append `repository/` to this path to form `docker_repository_path`.
|
||||
|
||||
If `docker_repository_path` is not defined, the role will automatically set it to:
|
||||
|
||||
```yaml
|
||||
"{{ docker_compose.directories.services }}repository/"
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
Kevin Veen-Birkenbach
|
||||
[https://www.veen.world](https://www.veen.world)
|
||||
|
||||
---
|
||||
|
||||
Happy deploying! 🚀🐳
|
7
roles/docker-repository-setup/handlers/main.yml
Normal file
7
roles/docker-repository-setup/handlers/main.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
- name: rebuild docker repository
|
||||
command:
|
||||
cmd: docker compose build
|
||||
chdir: "{{docker_repository_path}}"
|
||||
environment:
|
||||
COMPOSE_HTTP_TIMEOUT: 600
|
||||
DOCKER_CLIENT_TIMEOUT: 600
|
2
roles/docker-repository-setup/meta/main.yml
Normal file
2
roles/docker-repository-setup/meta/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- docker-compose # To load handlers and make dependencies visible
|
14
roles/docker-repository-setup/tasks/main.yml
Normal file
14
roles/docker-repository-setup/tasks/main.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
- name: Set default docker_repository_path if not defined
|
||||
set_fact:
|
||||
docker_repository_path: "{{docker_compose.directories.services}}repository/"
|
||||
when: docker_repository_path is not defined
|
||||
|
||||
- name: pull docker repository
|
||||
git:
|
||||
repo: "{{ docker_repository_address }}"
|
||||
dest: "{{ docker_repository_path }}"
|
||||
update: yes
|
||||
notify:
|
||||
- docker compose project setup
|
||||
- rebuild docker repository
|
||||
become: true
|
Reference in New Issue
Block a user