gi-yt.docker_compose_declarative
Docker Compose Declarative
This is a guide that helps you define Docker Compose settings in a clear way.
Role Variables
Check the file templates/docker-compose.yml.j2
for more details. A list of variables will be available soon! 😄
Required Environment Variables:
app
: Contains the main data for your compose setup.app_name
: The name of the stack you want to deploy.default_restart_policy
: Can be set to "unless-stopped", "never", or "always".configs_dir
: Where the configuration files for your stacks will be stored on the server.configs_dir_local
: Where the configuration files for your stacks will be stored in your code repository.compose_dir
: Where the Docker Compose file for your stacks will be stored on the server.data_dir
: Where the data for your stack will be stored on the server.
Example Playbook
Here’s a simple example you can follow:
- name: Docker
hosts: in
vars:
apps:
groups:
APP_NAME:
needs_configs_dir: true
needs_data_dir: true
docker_settings:
services:
- name: CONTAINER-1
image: REGISTRY_PATH
ports:
- "1234:5678"
environment:
A: "BCD"
mounts:
- "{{configs_dir}}/APP_NAME/config.yaml:/var/lib/app/config.yaml"
- "{{data_dir}}/APP_NAME/uploads:/var/lib/app/uploads"
command: "--some-arg-here"
user: 1000
tasks:
- name: Deploy stack role
ansible.builtin.include_role:
name: aryak.docker_compose_declarative
vars:
app: "{{ item.value }}"
app_name: "{{ item.key | lower }}"
default_restart_policy: unless-stopped
configs_dir: "/opt/configs"
configs_dir_local: "./configs/{{ item.key }}"
compose_dir: "/opt/docker"
data_dir: "/opt/docker"
loop: "{{ apps.groups | dict2items }}"
when: item.value.docker_settings
License
This work is licensed under AGPL 3.0.
Author Information
Created by Arya Kiran me@aryak.me
Informazioni sul progetto
A role to help automate docker compose deployments
Installa
ansible-galaxy install gi-yt.docker_compose_declarative
Licenza
Unknown
Download
200
Proprietario
I do not use github anymore, Find me on https://codeberg.org/aryak. Contact details at https://aryak.me/contact.html