Skip to content

Commit 53bc5a3

Browse files
committed
feat: add custom docker build
Signed-off-by: Dup4 <[email protected]>
1 parent b291368 commit 53bc5a3

File tree

12 files changed

+455
-3
lines changed

12 files changed

+455
-3
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
charset = utf-8
9+
indent_size = 4
10+
indent_style = space
11+
12+
[*.{yml,yaml}]
13+
charset = utf-8
14+
indent_style = space
15+
indent_size = 2

.github/workflows/build_chroot.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#
2+
name: Build Chroot
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "version"
9+
required: true
10+
default: "latest"
11+
repo:
12+
description: "repo"
13+
required: true
14+
default: "DOMjudge/domjudge"
15+
commit_id:
16+
description: "git commit id"
17+
required: false
18+
19+
jobs:
20+
build-chroot:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v2
25+
26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v1
28+
with:
29+
image: tonistiigi/binfmt:latest
30+
platforms: all
31+
32+
- name: Available platforms
33+
run: echo ${{ steps.qemu.outputs.platforms }}
34+
35+
- name: Set up Docker Buildx
36+
id: buildx
37+
uses: docker/setup-buildx-action@v1
38+
39+
- name: Inspect builder
40+
run: |
41+
echo "Name: ${{ steps.buildx.outputs.name }}"
42+
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
43+
echo "Status: ${{ steps.buildx.outputs.status }}"
44+
echo "Flags: ${{ steps.buildx.outputs.flags }}"
45+
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
46+
47+
- name: Login to Docker Hub
48+
uses: docker/login-action@v1
49+
with:
50+
username: ${{ secrets.DOCKERHUB_USERNAME }}
51+
password: ${{ secrets.DOCKERHUB_TOKEN }}
52+
53+
- name: Download DOMjudge
54+
run: |
55+
bash ./docker/download.sh ${{ github.event.inputs.version }} ${{ github.event.inputs.repo }} ${{ github.event.inputs.commit_id }}
56+
57+
- name: Build and Push
58+
uses: docker/build-push-action@v2
59+
with:
60+
context: ./docker
61+
file: ./docker/judgehost/Dockerfile.chroot
62+
platforms: linux/amd64,linux/arm64
63+
push: true
64+
tags: dup4/domjudge-default-judgehost-chroot:${{ github.event.inputs.version }}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#
2+
name: Build Domserver
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "version"
9+
required: true
10+
default: "latest"
11+
repo:
12+
description: "repo"
13+
required: true
14+
default: "DOMjudge/domjudge"
15+
commit_id:
16+
description: "git commit id"
17+
required: false
18+
19+
jobs:
20+
build-domserver:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Set up QEMU
27+
id: qemu
28+
uses: docker/setup-qemu-action@v3
29+
with:
30+
image: tonistiigi/binfmt:latest
31+
platforms: all
32+
33+
- name: Available platforms
34+
run: echo ${{ steps.qemu.outputs.platforms }}
35+
36+
- name: Set up Docker Buildx
37+
id: buildx
38+
uses: docker/setup-buildx-action@v3
39+
40+
- name: Inspect builder
41+
run: |
42+
echo "Name: ${{ steps.buildx.outputs.name }}"
43+
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
44+
echo "Status: ${{ steps.buildx.outputs.status }}"
45+
echo "Flags: ${{ steps.buildx.outputs.flags }}"
46+
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
47+
48+
- name: Login to Docker Hub
49+
uses: docker/login-action@v3
50+
with:
51+
username: ${{ secrets.DOCKERHUB_USERNAME }}
52+
password: ${{ secrets.DOCKERHUB_TOKEN }}
53+
54+
- name: Login to ALiYun Shanghai Container Registry
55+
uses: docker/login-action@v3
56+
with:
57+
registry: registry.cn-shanghai.aliyuncs.com
58+
username: ${{ secrets.ALIYUN_REGISTRY_USERNAME }}
59+
password: ${{ secrets.ALIYUN_REGISTRY_TOKEN }}
60+
61+
- name: Download DOMjudge
62+
run: |
63+
bash ./docker/download.sh ${{ github.event.inputs.version }} ${{ github.event.inputs.repo }} ${{ github.event.inputs.commit_id }}
64+
65+
- name: Build and Push
66+
uses: docker/build-push-action@v5
67+
env:
68+
registry_namespace: dup4
69+
image_name: domjudge-domserver
70+
tag: ${{ github.event.inputs.version }}
71+
with:
72+
context: ./docker
73+
file: ./docker/domserver/Dockerfile
74+
platforms: linux/amd64,linux/arm64
75+
push: true
76+
tags: |
77+
${{ env.registry_namespace }}/${{ env.image_name }}:${{ env.tag }}
78+
registry.cn-shanghai.aliyuncs.com/${{ env.registry_namespace }}/${{ env.image_name }}:${{ env.tag }}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#
2+
name: Build Judgehost
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "version"
9+
required: true
10+
default: "latest"
11+
repo:
12+
description: "repo"
13+
required: true
14+
default: "DOMjudge/domjudge"
15+
commit_id:
16+
description: "git commit id"
17+
required: false
18+
19+
jobs:
20+
build-judgehost:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Set up QEMU
27+
id: qemu
28+
uses: docker/setup-qemu-action@v3
29+
with:
30+
image: tonistiigi/binfmt:latest
31+
platforms: all
32+
33+
- name: Available platforms
34+
run: echo ${{ steps.qemu.outputs.platforms }}
35+
36+
- name: Set up Docker Buildx
37+
id: buildx
38+
uses: docker/setup-buildx-action@v3
39+
40+
- name: Inspect builder
41+
run: |
42+
echo "Name: ${{ steps.buildx.outputs.name }}"
43+
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
44+
echo "Status: ${{ steps.buildx.outputs.status }}"
45+
echo "Flags: ${{ steps.buildx.outputs.flags }}"
46+
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
47+
48+
- name: Login to Docker Hub
49+
uses: docker/login-action@v3
50+
with:
51+
username: ${{ secrets.DOCKERHUB_USERNAME }}
52+
password: ${{ secrets.DOCKERHUB_TOKEN }}
53+
54+
- name: Login to ALiYun Shanghai Container Registry
55+
uses: docker/login-action@v3
56+
with:
57+
registry: registry.cn-shanghai.aliyuncs.com
58+
username: ${{ secrets.ALIYUN_REGISTRY_USERNAME }}
59+
password: ${{ secrets.ALIYUN_REGISTRY_TOKEN }}
60+
61+
- name: Download DOMjudge
62+
run: |
63+
bash ./docker/download.sh ${{ github.event.inputs.version }} ${{ github.event.inputs.repo }} ${{ github.event.inputs.commit_id }}
64+
65+
- name: Build
66+
env:
67+
tag: ${{ github.event.inputs.version }}
68+
run: |
69+
cd ./docker
70+
sudo bash -e build-judgehost.sh dup4/domjudge-judgehost:${{ env.tag }}
71+
72+
- name: Push
73+
env:
74+
registry_namespace: dup4
75+
image_name: domjudge-judgehost
76+
tag: ${{ github.event.inputs.version }}
77+
run: |
78+
docker push ${{ env.registry_namespace }}/${{ env.image_name }}:${{ env.tag }}
79+
docker tag ${{ env.registry_namespace }}/${{ env.image_name }}:${{ env.tag }} registry.cn-shanghai.aliyuncs.com/${{ env.registry_namespace }}/${{ env.image_name }}:${{ env.tag }}
80+
docker push registry.cn-shanghai.aliyuncs.com/${{ env.registry_namespace }}/${{ env.image_name }}:${{ env.tag }}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#
2+
name: Build Judgehost In Docker
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "version"
9+
required: true
10+
default: "latest"
11+
repo:
12+
description: "repo"
13+
required: true
14+
default: "DOMjudge/domjudge"
15+
commit_id:
16+
description: "git commit id"
17+
required: false
18+
19+
jobs:
20+
build-judgehost-in-docker:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v2
25+
26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v1
28+
with:
29+
image: tonistiigi/binfmt:latest
30+
platforms: all
31+
32+
- name: Available platforms
33+
run: echo ${{ steps.qemu.outputs.platforms }}
34+
35+
- name: Set up Docker Buildx
36+
id: buildx
37+
uses: docker/setup-buildx-action@v1
38+
39+
- name: Inspect builder
40+
run: |
41+
echo "Name: ${{ steps.buildx.outputs.name }}"
42+
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
43+
echo "Status: ${{ steps.buildx.outputs.status }}"
44+
echo "Flags: ${{ steps.buildx.outputs.flags }}"
45+
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
46+
47+
- name: Login to Docker Hub
48+
uses: docker/login-action@v1
49+
with:
50+
username: ${{ secrets.DOCKERHUB_USERNAME }}
51+
password: ${{ secrets.DOCKERHUB_TOKEN }}
52+
53+
- name: Download DOMjudge
54+
run: |
55+
bash ./docker/download.sh ${{ github.event.inputs.version }} ${{ github.event.inputs.repo }} ${{ github.event.inputs.commit_id }}
56+
57+
- name: Build and Push
58+
uses: docker/build-push-action@v2
59+
with:
60+
context: ./docker
61+
file: ./docker/judgehost/Dockerfile.all
62+
platforms: linux/amd64,linux/arm64
63+
allow: security.insecure
64+
push: true
65+
tags: dup4/domjudge-judgehost:${{ github.event.inputs.version }}

.github/workflows/shellcheck.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ jobs:
1616
- uses: actions/checkout@v2
1717
- name: Run ShellCheck
1818
uses: ludeeus/action-shellcheck@master
19+
with:
20+
severity: error

.vscode/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"editor.tabSize": 4,
3+
"editor.insertSpaces": true,
4+
"editor.formatOnSave": true,
5+
"files.trimTrailingWhitespace": true,
6+
"files.insertFinalNewline": true,
7+
"files.trimFinalNewlines": true,
8+
"cSpell.words": [
9+
"buildx",
10+
"DOCKERHUB",
11+
"domjudge",
12+
"judgehost",
13+
"shellcheck"
14+
],
15+
}

docker/download.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#! /bin/bash
2+
3+
TOP_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
4+
FILE_NAME="domjudge"
5+
FILE="${TOP_DIR}/${FILE_NAME}.tar.gz"
6+
DIR="${TOP_DIR}/${FILE_NAME}"
7+
8+
VERSION="${1}"
9+
REPO="${2}"
10+
COMMIT_ID="${3}"
11+
12+
if [[ -z "${VERSION}" ]]; then
13+
VERSION="latest"
14+
fi
15+
16+
if [[ -z "${REPO}" ]]; then
17+
REPO="DOMjudge/domjudge"
18+
fi
19+
20+
if command -v git >/dev/null 2>&1; then
21+
GIT_COMMAND="git clone https://github.com/${REPO}.git"
22+
if [[ -z "${COMMIT_ID}" ]] && [[ X"${VERSION}" != X"latest" ]]; then
23+
GIT_COMMAND="${GIT_COMMAND} -b ${VERSION}"
24+
fi
25+
26+
GIT_COMMAND="${GIT_COMMAND} ${DIR}"
27+
28+
${GIT_COMMAND}
29+
30+
if [[ -n "${COMMIT_ID}" ]]; then
31+
cd "${DIR}" || exit 1
32+
git reset --hard "${COMMIT_ID}"
33+
cd - || exit 1
34+
fi
35+
36+
tar -cvzf "${FILE}" -C "${TOP_DIR}" "${FILE_NAME}"
37+
rm -rf "${DIR}"
38+
else
39+
if [[ X"${VERSION}" = X"latest" ]]; then
40+
URL=https://codeload.github.com/${REPO}/tar.gz/refs/heads/main
41+
else
42+
URL=https://codeload.github.com/${REPO}/tar.gz/refs/tags/${VERSION}
43+
fi
44+
45+
echo "[..] Downloading DOMjudge version ${VERSION}..."
46+
47+
if ! wget --quiet "${URL}" -O "${FILE}"; then
48+
echo "[!!] DOMjudge version ${VERSION} file not found on https://codeload.github.com/DOMjudge/domjudge"
49+
exit 1
50+
fi
51+
fi

docker/judgehost/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM debian:bookworm
1+
FROM ubuntu:jammy
22
LABEL org.opencontainers.image.authors="DOMjudge team <[email protected]>"
33

44
ENV DEBIAN_FRONTEND=noninteractive \

0 commit comments

Comments
 (0)