Fixes #1: Vorschlag für ein docker-compose #3

Closed
damihe wants to merge 1 commits from 1-docker-compose into main
3 changed files with 82 additions and 53 deletions

15
handlers/main.yml Normal file
View File

@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2021 WTF Kooperative eG <https://wtf-eg.de/>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
---
- name: docker-compose up -d for ki
become: true
ansible.builtin.command:
cmd: docker-compose up -d
chdir: /var/docker/ki
- name: docker-compose restart for ki
become: true
ansible.builtin.command:
cmd: docker-compose restart
chdir: /var/docker/ki

View File

@ -3,10 +3,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
--- ---
- name: be sure the ki network exists
community.general.docker_network:
name: ki
- name: "be sure the {{ item }} volume exists" - name: "be sure the {{ item }} volume exists"
docker_volume: docker_volume:
name: "{{ item }}" name: "{{ item }}"
@ -14,66 +10,42 @@
- ki_data - ki_data
- ki_db - ki_db
- name: be sure the ki config directory exists - name: be sure the ki docker directory exists
become: true become: true
file: file:
path: /etc/ki path: /var/docker/ki
state: directory state: directory
owner: root owner: root
group: root group: root
mode: "0755" mode: "0755"
- name: be sure the ki config directory exists
become: true
file:
path: /var/docker/ki/data
state: directory
owner: root
group: root
mode: "0755"
- name: docker-compose file for services
become: true
ansible.builtin.template:
src: docker-compose.yml.j2
dest: /var/docker/ki/docker-compose.yml
owner: root
group: root
mode: "0644"
notify:
- docker-compose up -d for ki
- name: be sure the ki-frontend config file is in place - name: be sure the ki-frontend config file is in place
become: true become: true
template: template:
src: frontend.js src: frontend.js
dest: /etc/ki/frontend.js dest: /var/docker/ki/data/frontend.js
owner: root owner: root
group: root group: root
mode: "0655" mode: "0655"
notify:
- name: be sure the ki_database container is running - docker-compose restart for ki
community.general.docker_container:
name: ki_db
image: "{{ ki_db_image }}"
pull: no
restart_policy: unless-stopped
env:
MYSQL_ROOT_PASSWORD: "{{ ki_db_root_password }}"
MYSQL_DATABASE: ki
MYSQL_USER: ki
MYSQL_PASSWORD: "{{ ki_db_password }}"
volumes:
- ki_db:/var/lib/mysql/
networks:
- name: ki
- name: be sure the ki_backend container is running
community.general.docker_container:
name: ki_backend
image: "{{ ki_backend_image }}"
pull: yes
restart_policy: unless-stopped
env:
SQLALCHEMY_DATABASE_URI: "mariadb+pymysql://ki:{{ ki_db_password }}@ki_db:3306/ki"
FLASK_ENV: "development"
KI_LOGLEVEL: "10"
KI_AUTH: "file"
CORS_ORIGINS: "{{ ki_frontend_uri }}"
ports:
- "{{ ki_backend_port }}:5000"
volumes:
- ki_data:/app/data/
networks:
- name: ki
- name: be sure the ki_frontend container is running
community.general.docker_container:
name: ki_frontend
image: "{{ ki_frontend_image }}"
pull: yes
restart_policy: unless-stopped
ports:
- "{{ ki_frontend_port }}:80"
volumes:
- /etc/ki/frontend.js:/usr/share/nginx/html/config.js

View File

@ -0,0 +1,42 @@
# Deployed through Ansible
version: '3'
services:
ki_db:
image: {{ ki_db_image }}
restart: unless-stopped
environment:
- "MYSQL_ROOT_PASSWORD={{ ki_db_root_password }}"
- "MYSQL_DATABASE=ki"
- "MYSQL_USER=ki"
- "MYSQL_PASSWORD={{ ki_db_password }}"
volumes:
- ki_db:/var/lib/mysql/
networks:
- ki
ki_backend:
image: {{ ki_backend_image }}
restart: unless-stopped
environment:
- "SQLALCHEMY_DATABASE_URI=mariadb+pymysql://ki:{{ ki_db_password }}@ki_db:3306/ki"
- "FLASK_ENV=development"
- "KI_LOGLEVEL=10"
- "KI_AUTH=file"
- "CORS_ORIGINS={{ ki_frontend_uri }}"
ports:
- "127.0.0.1:{{ ki_backend_port }}:5000"
volumes:
- ki_data:/app/data/
networks:
- ki
ki_frontend:
image: {{ ki_frontend_image }}
restart: unless-stopped
ports:
- "127.0.0.1:{{ ki_frontend_port }}:80"
volumes:
- ./data/frontend.js:/usr/share/nginx/html/config.js
networks:
- default
networks:
default: {}
ki: {}