This commit is contained in:
Kevin Veen-Birkenbach 2023-12-24 18:48:38 +01:00
parent f1c912924e
commit bc086d5236
4 changed files with 155 additions and 11 deletions

View File

@ -2,11 +2,24 @@
- name: "include tasks nginx-docker-proxy-domain.yml" - name: "include tasks nginx-docker-proxy-domain.yml"
include_tasks: nginx-docker-proxy-domain.yml include_tasks: nginx-docker-proxy-domain.yml
- name: "create {{ repository_directory }}" - name: register repository_directory_register
file: stat:
path: "{{repository_directory}}" path: "{{repository_directory}}"
state: directory register: repository_directory_register
mode: 0755
- 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: pull docker repository - name: pull docker repository
git: git:
@ -16,7 +29,13 @@
notify: recreate openproject notify: recreate openproject
become: true become: true
register: git_result register: git_result
ignore_errors: true
- 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
- name: Warn if repo is not reachable - name: Warn if repo is not reachable
debug: debug:
@ -28,3 +47,9 @@
src: env.j2 src: env.j2
dest: "{{ docker_compose_instance_directory }}.env" dest: "{{ docker_compose_instance_directory }}.env"
notify: recreate openproject notify: recreate openproject
- name: "copy docker-compose.yml"
template:
src: docker-compose.yml.j2
dest: "{{ docker_compose_file_path }}"
notify: recreate openproject

View File

@ -0,0 +1,117 @@
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 RAILS_MAX_THREADS=16
# The following volumes are default # The following volumes are default
# PGDATA="pgdata" PGDATA="pgdata"
# OPDATA="opdata" OPDATA="opdata"

View File

@ -1,2 +1,4 @@
repository_directory: "{{ path_docker_compose_instances }}openproject/" repository_directory: "{{ path_docker_compose_instances }}openproject/"
docker_compose_instance_directory: "{{repository_directory}}compose/" 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"