Compare commits

..

No commits in common. "d1b2d8e6537f5b4beeefe3a9381a6795554e8a79" and "d138458b94886234f429a6fcc89c1900c9b4a0e1" have entirely different histories.

5 changed files with 14 additions and 176 deletions

View File

@ -2,40 +2,21 @@
- name: "include tasks nginx-docker-proxy-domain.yml"
include_tasks: nginx-docker-proxy-domain.yml
- name: register repository_directory_register
stat:
path: "{{repository_directory}}"
register: repository_directory_register
- name: checkout repository
ansible.builtin.shell: git checkout .
become: true
args:
chdir: "{{repository_directory}}"
when: repository_directory_register.stat.exists
- name: "backup docker-compose.yml if it exists"
command: >
mv "{{ docker_compose_file_path }}" "{{ docker_compose_backup_path }}"
args:
removes: "{{ docker_compose_file_path }}"
become: true
- name: "create {{ repository_directory }}"
file:
path: "{{ repository_directory }}"
state: directory
mode: 0755
- name: pull docker repository
git:
repo: "https://github.com/opf/openproject-deploy"
dest: "{{ repository_directory }}"
dest: "{{repository_directory}}"
update: yes
notify: recreate openproject
become: true
register: git_result
- name: "restore docker-compose.yml from backup"
command: >
mv "{{ docker_compose_backup_path }}" "{{ docker_compose_file_path }}"
args:
removes: "{{ docker_compose_backup_path }}"
become: true
ignore_errors: true
- name: Warn if repo is not reachable
debug:
@ -45,11 +26,5 @@
- name: "copy .env"
template:
src: env.j2
dest: "{{ docker_compose_instance_directory }}.env"
notify: recreate openproject
- name: "copy docker-compose.yml"
template:
src: docker-compose.yml.j2
dest: "{{ docker_compose_file_path }}"
notify: recreate openproject
dest: "{{docker_compose_instance_directory}}.env"
notify: recreate openproject

View File

@ -1,117 +0,0 @@
version: "3.7"
networks:
frontend:
backend:
volumes:
pgdata:
opdata:
x-op-restart-policy: &restart_policy
restart: unless-stopped
x-op-image: &image
image: openproject/community:${TAG:-13}
x-op-app: &app
<<: [*image, *restart_policy]
environment:
OPENPROJECT_HTTPS: "${OPENPROJECT_HTTPS:-true}"
OPENPROJECT_HOST__NAME: "${OPENPROJECT_HOST__NAME:-localhost:8080}"
OPENPROJECT_HSTS: "${OPENPROJECT_HSTS:-true}"
RAILS_CACHE_STORE: "memcache"
OPENPROJECT_CACHE__MEMCACHE__SERVER: "cache:11211"
OPENPROJECT_RAILS__RELATIVE__URL__ROOT: "${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}"
DATABASE_URL: "${DATABASE_URL:-postgres://postgres:p4ssw0rd@db/openproject?pool=20&encoding=unicode&reconnect=true}"
RAILS_MIN_THREADS: ${RAILS_MIN_THREADS:-4}
RAILS_MAX_THREADS: ${RAILS_MAX_THREADS:-16}
# set to true to enable the email receiving feature. See ./docker/cron for more options
IMAP_ENABLED: "${IMAP_ENABLED:-false}"
volumes:
- "${OPDATA:-opdata}:/var/openproject/assets"
services:
db:
image: postgres:13
<<: *restart_policy
stop_grace_period: "3s"
volumes:
- "${PGDATA:-pgdata}:/var/lib/postgresql/data"
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-p4ssw0rd}
POSTGRES_DB: openproject
networks:
- backend
cache:
image: memcached
<<: *restart_policy
networks:
- backend
proxy:
<<: [*image, *restart_policy]
command: "./docker/prod/proxy"
ports:
- "${PORT:-8080}:80"
environment:
APP_HOST: web
OPENPROJECT_RAILS__RELATIVE__URL__ROOT: "${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}"
depends_on:
- web
networks:
- frontend
web:
<<: *app
command: "./docker/prod/web"
networks:
- frontend
- backend
depends_on:
- db
- cache
- seeder
labels:
- autoheal=true
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}/health_checks/default"]
interval: 10s
timeout: 3s
retries: 3
start_period: 30s
autoheal:
image: willfarrell/autoheal:1.2.0
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
environment:
AUTOHEAL_CONTAINER_LABEL: autoheal
AUTOHEAL_START_PERIOD: 600
AUTOHEAL_INTERVAL: 30
worker:
<<: *app
command: "./docker/prod/worker"
networks:
- backend
depends_on:
- db
- cache
- seeder
cron:
<<: *app
command: "./docker/prod/cron"
networks:
- backend
depends_on:
- db
- cache
- seeder
seeder:
<<: *app
command: "./docker/prod/seeder"
restart: on-failure
networks:
- backend

View File

@ -18,5 +18,5 @@ RAILS_MIN_THREADS=4
RAILS_MAX_THREADS=16
# The following volumes are default
PGDATA="pgdata"
OPDATA="opdata"
# PGDATA="pgdata"
# OPDATA="opdata"

View File

@ -1,4 +1,2 @@
repository_directory: "{{ path_docker_compose_instances }}openproject/"
docker_compose_instance_directory: "{{repository_directory}}compose/"
docker_compose_file_path: "{{docker_compose_instance_directory}}docker-compose.yml"
docker_compose_backup_path: "/tmp/openproject-docker-compose-backup.yml"

View File

@ -4,9 +4,6 @@
#
import subprocess
import time
import os
errors = 0
def bash(command):
print(command)
@ -29,13 +26,6 @@ def print_bash(command):
print(list_to_string(output))
return output
def find_docker_compose_file(directory):
for root, _, files in os.walk(directory):
for file in files:
if file == 'docker-compose.yml':
return os.path.join(root, file)
return None
waiting_time=600
blocker_running=True
while blocker_running:
@ -58,16 +48,8 @@ for failed_container in failed_containers:
unfiltered_failed_docker_compose_repositories.append(failed_container.split('-')[0])
filtered_failed_docker_compose_repositories=list(dict.fromkeys(unfiltered_failed_docker_compose_repositories))
for filtered_failed_docker_compose_repository in filtered_failed_docker_compose_repositories:
compose_file_path = find_docker_compose_file('/home/administrator/docker-compose/' + filtered_failed_docker_compose_repository)
if compose_file_path:
print("Restarting unhealthy container in:", compose_file_path)
print_bash(f'cd {os.path.dirname(compose_file_path)} && docker-compose restart')
else:
print("Error: Docker Compose file not found for:", filtered_failed_docker_compose_repository)
errors += 1
print("restarting unhealthy container: " + filtered_failed_docker_compose_repository)
print_bash('cd /home/administrator/docker-compose/' + filtered_failed_docker_compose_repository + '/ && docker-compose restart')
print("finished restart procedure.")
exit(errors)
print("finished restart procedure.")