Feat(domserver): docker compose testing #1

Merged
ytshih merged 16 commits from ytshih/testing into main 2025-04-07 20:44:26 +08:00
6 changed files with 75 additions and 1 deletions
Showing only changes of commit 7f72c71f10 - Show all commits

3
group_vars/all/main.yml Normal file
View File

@@ -0,0 +1,3 @@
---
domjudge_base_dir: /opt/domjudge/midterm
domserver_url: https://cp1.konchin.com

View File

@@ -1,4 +1,3 @@
--- ---
domjudge_base_dir: /opt/domjudge/midterm
mariadb_version: 11.7.2 mariadb_version: 11.7.2
domserver_version: 8.3.1 domserver_version: 8.3.1

6
playbooks/judgehost.yml Normal file
View File

@@ -0,0 +1,6 @@
---
- name: Install judgehost
hosts: judgehost
roles:
- role: install_packages
- role: configure_judgehost

View File

@@ -0,0 +1,6 @@
---
- name: Restart judgehost docker compose
community.docker.docker_compose_v2:
project_src: "{{ domjudge_base_dir }}"
state: restarted
remove_orphans: true

View File

@@ -7,3 +7,51 @@
cgroup_enable=memory cgroup_enable=memory
swapaccount=1 swapaccount=1
systemd.unified_cgroup_hierarchy=0 systemd.unified_cgroup_hierarchy=0
notify: Reboot
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- name: Fetch judgehost password
community.docker.docker_compose_v2_exec:
project_src: "{{ domjudge_base_dir }}"
service: domserver
command: >-
sed -nr 's/^.*\W+judgehost\W+(.+)$/\1/p'
/opt/domjudge/domserver/etc/restapi.secret
register: fetch_reg
- name: Set judgehost facts
ansible.builtin.set_fact:
domserver_url: "{{ domserver_url }}"
judgehost_password: "{{ fetch_reg['stdout'] }}"
delegate_to: domserver[0]
run_once: true
- name: Show judgehost password
ansible.builtin.debug:
var: judgehost_password
- name: Install judgehost directory
ansible.builtin.file:
path: "{{ domjudge_base_dir }}"
state: directory
mode: '0750'
owner: root
group: docker
- name: Install judgehost docker compose
notify:
- Restart judgehost docker compose
block:
- name: Install docker-compose.yml
ansible.builtin.template:
src: docker-compose.yml.jinja
dest: "{{ domjudge_base_dir }}/docker-compose.yml"
mode: '0644'
owner: root
group: root
- name: Enable and start docker
ansible.builtin.systemd_service:
name: docker.service
state: started
enabled: true
- name: Run docker compose up
community.docker.docker_compose_v2:
project_src: "{{ domjudge_base_dir }}"

View File

@@ -0,0 +1,12 @@
services:
judgehost:
image: domjudge/judgehost:{{ judgehost_version }}
privileged: true
environment:
DAEMON_ID: 0
DOMSERVER_BASEURL: {{ domserver_url }}
JUDGEDAEMON_USERNAME: judgehost
JUDGEDAEMON_PASSWORD: {{ judgehost_password }}
DOMJUDGE_CREATE_WRITABLE_TEMP_DIR: 1
CONTAINER_TIMEZONE: Asia/Taipei
restart: always