Feat(domserver): docker compose testing

This commit is contained in:
2025-04-06 18:11:00 +08:00
parent c2de82bd9f
commit 21a5b1b4f6
11 changed files with 124 additions and 0 deletions

4
ansible.cfg Normal file
View File

@@ -0,0 +1,4 @@
[defaults]
roles_path=./roles/
inventory=./hosts
remote_user=root

View File

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

13
hosts Normal file
View File

@@ -0,0 +1,13 @@
[control]
localhost ansible_connection=local
[domserver]
10.4.2.226
# 140.113.168.160
[judgehost]
10.4.2.227
10.4.2.228
[all:vars]
ansible_python_interpreter=/usr/bin/python

View File

@@ -0,0 +1,4 @@
[mariadb]
max_connections = 1000
innodb_log_file_size = 4096MB
max_allowed_packet = 4096MB

View File

@@ -0,0 +1,5 @@
; Set these three to be at least the size of your largest testcase and
; largest expected program output.
php_admin_value[memory_limit] = 4096M
php_admin_value[upload_max_filesize] = 4096M
php_admin_value[post_max_size] = 4096M

View File

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

View File

@@ -0,0 +1,38 @@
---
- name: Install domjudge directory
ansible.builtin.file:
path: "{{ domjudge_base_dir }}"
state: directory
mode: '0755'
owner: root
group: root
- name: Install domjudge docker compose
notify:
- Restart domjudge 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: Install mysql config
ansible.builtin.copy:
src: config/mysql
dest: "{{ domjudge_base_dir }}/config/mysql"
mode: '0755'
owner: root
group: root
- name: Install domserver php config
ansible.builtin.copy:
src: config/php
dest: "{{ domjudge_base_dir }}/config/php"
mode: '0755'
owner: root
group: root
- name: Enable and start docker
ansible.builtin.systemd_service:
name: docker.service
state: started
enabled: true

View File

@@ -0,0 +1,28 @@
services:
mariadb:
image: mariadb:{{ mariadb_version }}
environment:
MYSQL_USER: domjudge
MYSQL_DATABASE: domjudge
MYSQL_PASSWORD: "{{ mysql_password }}"
MYSQL_ROOT_PASSWORD: "{{ mysql_root_password }}"
restart: always
volumes:
- "./data/mariadb:/var/lib/mysql"
- "./config/mysql:/etc/mysql/conf.d:ro"
domserver:
build:
context: .
dockerfile_inline: |
FROM domjudge/domserver:{{ domserver_version }}
COPY ./config/php/domjudge.conf /etc/php/8.2/fpm/pool.d/domjudge.conf
environment:
MYSQL_HOST: mariadb
MYSQL_USER: domjudge
MYSQL_DATABASE: domjudge
MYSQL_PASSWORD: "{{ mysql_password }}"
MYSQL_ROOT_PASSWORD: "{{ mysql_root_password }}"
CONTAINER_TIMEZONE: Asia/Taipei
restart: always
ports:
- "8080:80"

View File

@@ -0,0 +1,9 @@
---
- name: Add boot parameters
ansible.builtin.lineinfile:
path: /boot/loader/entries/arch.conf
line: >-
options
cgroup_enable=memory
swapaccount=1
systemd.unified_cgroup_hierarchy=0

View File

@@ -0,0 +1,4 @@
---
- name: Upgrade packages
community.general.pacman:
upgrade: true

View File

@@ -0,0 +1,9 @@
---
- name: Update package cache
community.general.pacman:
update_cache: true
- name: Install docker
community.general.pacman:
pkg:
- docker
notify: Upgrade packages