Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with domjudge repo #181

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1e740bd
Add docker workflow
robertdijk Mar 30, 2022
a930ce5
Change baseurl to chipcie url
robertdijk Apr 14, 2022
b2c3ef3
Add support for printer
robertdijk Apr 24, 2022
28d4513
Merge branch 'DOMjudge:main' into master
robertdijk Jun 11, 2022
2c536de
Fix building judgehost in github workflow
robertdijk Jun 13, 2022
d62ec69
Add patches to change defualt config
robertdijk Jun 18, 2022
548e37c
Add patch to source kotlin in the kotlin run file
robertdijk Jun 18, 2022
97c4c95
Add script to add more repositories
robertdijk Jun 18, 2022
a17e3de
Install additional languages
robertdijk Jun 18, 2022
77c5fa6
Use Ubuntu 22.04 for judgehosts
robertdijk Jun 18, 2022
5fa8bc9
Fix path to kotlin run file
robertdijk Jun 18, 2022
4c0aa48
Merge branch 'DOMjudge:main' into master
robertdijk Jun 18, 2022
da8f277
Update icpc repo
robertdijk Jul 2, 2022
3f3cfd9
Rename kotlin script
robertdijk Jul 2, 2022
0c62c45
Merge branch 'master' of github.com:WISVCH/domjudge-packaging
robertdijk Jul 2, 2022
88f6f01
Add automatically importing affiliations
robertdijk Jul 29, 2022
547eaf6
Update default config
robertdijk Jul 31, 2022
eb13819
Enable kotlin by default
robertdijk Aug 19, 2022
8741b9c
Add DOMjudge team to admin
robertdijk Aug 19, 2022
5c29c00
Update kotlin script
robertdijk Oct 15, 2022
1332bea
Set C and CPP standard
robertdijk Oct 19, 2022
102604e
Merge branch 'DOMjudge:main' into master
robertdijk Oct 19, 2022
f8cba0e
Merge branch 'DOMjudge:main' into master
robertdijk Nov 16, 2022
ac22f2d
Only download affiliation logos, and change to transparent
robertdijk Nov 20, 2022
7f79165
Update workflow to support branches
robertdijk Dec 29, 2022
1f4effc
Merge branch 'DOMjudge:main' into master
robertdijk Feb 23, 2023
e421e0f
Merge branch 'DOMjudge:main' into master
robertdijk Apr 14, 2023
138ac93
Make set kotlin location executable
robertdijk May 25, 2023
76806da
Merge remote-tracking branch 'upstream/main'
robertdijk Aug 3, 2023
45250ef
Update 30-enable-kotlin.py
robertdijk Aug 3, 2023
bc956ad
Update judgehost and apt repo to jammy
maartenweyns Sep 15, 2023
f992d6a
Change icpc-logos repo location
maartenweyns Nov 5, 2023
f84320c
Fixup PHP version to 8.?
agcom Oct 9, 2023
78897a7
Update domserver base to Debian bookworm
maartenweyns Nov 8, 2023
8c6cd89
Add python3-yaml apt package
maartenweyns Nov 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions .github/workflows/build_and_push_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
---
name: 'Build version'

on:
push:
branches:
- master
workflow_dispatch:
inputs:
version:
required: false

env:
REGISTRY: ghcr.io
REPO_NAME: ${{ github.repository }}

jobs:
get_version:
runs-on: ubuntu-latest
outputs:
docker_tags: ${{ steps.dowload_domjudge.outputs.docker_tags }}
domjudge_cache_key: ${{ steps.domjudge_cache_key.outputs.domjudge_cache_key }}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Download Domjudge
id: dowload_domjudge
run: |
FILE="domjudge.tar.gz"
REPO="DOMjudge/domjudge"
INPUT_VERSION=${{ github.event.inputs.version }}
DOCKER_TAGS=( "latest" )
DOCKER_TAGS+=( "packaging-$(git rev-parse --short HEAD)" )

DJ_TAGS=$(curl -s https://api.github.com/repos/${REPO}/git/refs/tags | jq 'reverse | ((.[].ref) / "refs/tags/" )[1]' | rev | cut -c2- | rev | cut -c2-)
RELEASE_VERSION=$(echo "${DJ_TAGS}" | head -n 1)
TAG_TO_BUILD=""

if [[ "$INPUT_VERSION" == "" || "$INPUT_VERSION" == "release" || "$INPUT_VERSION" == "$RELEASE_VERSION" ]]; then
TAG_TO_BUILD=$RELEASE_VERSION
DOCKER_TAGS+=( "$RELEASE_VERSION" )
fi

if [[ "$TAG_TO_BUILD" == "" ]] && echo "$DJ_TAGS" | grep -F -q -x "$INPUT_VERSION"; then
TAG_TO_BUILD=$INPUT_VERSION
DOCKER_TAGS+=( "$INPUT_VERSION" )
fi

if [[ "$TAG_TO_BUILD" != "" ]]; then
echo "DOCKER_TAGS: ${DOCKER_TAGS[*]}"
echo "TAG_TO_BUILD: $TAG_TO_BUILD"
echo "docker_tags=${DOCKER_TAGS[*]}" >> $GITHUB_OUTPUT
wget "https://github.com/${REPO}/archive/refs/tags/${TAG_TO_BUILD}.tar.gz" -O ${FILE}
exit 0
fi

DJ_BRANCHES=$(curl -s https://api.github.com/repos/${REPO}/branches | jq '.[].name' | rev | cut -c2- | rev | cut -c2-)
BRANCH_TO_BUILD=""

if [[ "$BRANCH_TO_BUILD" == "" ]] && echo "$DJ_BRANCHES" | grep -F -q -x "$INPUT_VERSION"; then
BRANCH_TO_BUILD=$INPUT_VERSION
DOCKER_TAGS+=( "$INPUT_VERSION" )
fi

if [[ "$BRANCH_TO_BUILD" != "" ]]; then
echo "DOCKER_TAGS: ${DOCKER_TAGS[*]}"
echo "BRANCH_TO_BUILD: $BRANCH_TO_BUILD"
echo "docker_tags=${DOCKER_TAGS[*]}" >> $GITHUB_OUTPUT
wget "https://github.com/${REPO}/archive/refs/heads/${BRANCH_TO_BUILD}.tar.gz" -O ${FILE}
exit 0
fi

DJ_COMMITS=$(curl -s https://api.github.com/repos/${REPO}/commits | jq '.[].sha' | rev | cut -c2- | rev | cut -c2-)
COMMIT_TO_BUILD=""

if [[ "$COMMIT_TO_BUILD" == "" ]] && echo "$DJ_COMMITS" | grep -F -q -x "$INPUT_VERSION"; then
COMMIT_TO_BUILD=$INPUT_VERSION
DOCKER_TAGS+=( "$INPUT_VERSION" )
fi

if [[ "$COMMIT_TO_BUILD" != "" ]]; then
echo "DOCKER_TAGS: ${DOCKER_TAGS[*]}"
echo "COMMIT_TO_BUILD: $COMMIT_TO_BUILD"
echo "docker_tags=${DOCKER_TAGS[*]}" >> $GITHUB_OUTPUT
wget "https://github.com/${REPO}/archive/${COMMIT_TO_BUILD}.tar.gz" -O ${FILE}
exit 0
fi

exit 1
- id: domjudge_cache_key
run: echo "domjudge_cache_key=${{ runner.os }}-${{ hashFiles('domjudge.tar.gz') }}" >> $GITHUB_OUTPUT
- name: Print docker tags
run: echo ${{ steps.dowload_domjudge.outputs.docker_tags }}
- uses: actions/cache@v3
with:
path: domjudge.tar.gz
key: ${{ runner.os }}-${{ hashFiles('domjudge.tar.gz') }}

build_domserver:
needs: get_version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- uses: actions/cache@v3
with:
path: domjudge.tar.gz
key: ${{ needs.get_version.outputs.domjudge_cache_key }}

- run: mv domjudge.tar.gz ./docker

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Build container
run: |
cd ./docker
sudo bash -e ./build-domjudge.sh "domjudge/domserver:chipcie"

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker tag and push
run: |
IMAGE_ID=$(echo ${{ env.REGISTRY }}/${{ env.REPO_NAME }} | tr '[A-Z]' '[a-z]')

for TAG in ${{ needs.get_version.outputs.docker_tags }}; do
docker tag domjudge/domserver:chipcie ${IMAGE_ID}/domserver:$TAG
docker push ${IMAGE_ID}/domserver:$TAG
done

build_judgehost:
needs: get_version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- uses: actions/cache@v3
with:
path: domjudge.tar.gz
key: ${{ needs.get_version.outputs.domjudge_cache_key }}

- run: mv domjudge.tar.gz ./docker

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Build container
run: |
cd ./docker
sudo bash -e ./build-judgehost.sh "domjudge/judgehost:chipcie"

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker tag and push
run: |
IMAGE_ID=$(echo ${{ env.REGISTRY }}/${{ env.REPO_NAME }} | tr '[A-Z]' '[a-z]')

for TAG in ${{ needs.get_version.outputs.docker_tags }}; do
docker tag domjudge/judgehost:chipcie ${IMAGE_ID}/judgehost:$TAG
docker push ${IMAGE_ID}/judgehost:$TAG
done
2 changes: 1 addition & 1 deletion docker/build-judgehost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docker build -t "${docker_tag}-build" -f judgehost/Dockerfile.build .
# Build chroot
builder_name=$(echo "${docker_tag}" | sed 's/[^a-zA-Z0-9_-]/-/g')
docker rm -f "${builder_name}" > /dev/null 2>&1 || true
docker run --name "${builder_name}" --cap-add=sys_admin "${docker_tag}-build"
docker run --privileged --name "${builder_name}" --cap-add=sys_admin "${docker_tag}-build"
docker cp "${builder_name}:/chroot.tar.gz" .
docker cp "${builder_name}:/judgehost.tar.gz" .
docker rm -f "${builder_name}"
Expand Down
20 changes: 15 additions & 5 deletions docker/domserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:bullseye-slim AS domserver-build
FROM debian:bookworm-slim AS domserver-build
LABEL org.opencontainers.image.authors="DOMjudge team <team@domjudge.org>"

ENV DEBIAN_FRONTEND=noninteractive
Expand All @@ -12,13 +12,16 @@ RUN apt update \
php-gd php-curl php-mysql php-json php-intl \
php-gmp php-xml php-mbstring \
sudo bsdmainutils ntp libcgroup-dev procps \
python3-sphinx python3-sphinx-rtd-theme python3-pygments rst2pdf fontconfig python3-yaml \
python3-venv python3-yaml fontconfig \
texlive-latex-recommended texlive-latex-extra \
texlive-fonts-recommended texlive-lang-european latexmk \
texlive-fonts-recommended texlive-lang-european latexmk tex-gyre \
libcurl4-gnutls-dev libjsoncpp-dev libmagic-dev \
enscript lpr ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Use venv to install latest Sphinx. 6.1.0 or higher is required to build DOMjudge docs.
RUN python3 -m venv /venv && . /venv/bin/activate && pip3 install sphinx sphinx-rtd-theme rst2pdf

# Set up user
RUN useradd -m domjudge

Expand All @@ -31,11 +34,16 @@ RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
ADD domjudge.tar.gz /domjudge-src
COPY domserver/build.sh /domjudge-src/build.sh

# Apply patches
COPY domserver/scripts/patches.sh /scripts/patches.sh
COPY domserver/scripts/patches.d /scripts/patches.d
RUN chmod 700 /scripts/patches.sh && /scripts/patches.sh

# Build and install domserver
RUN /domjudge-src/build.sh

# Now create an image with the actual build in it
FROM debian:bullseye-slim
FROM debian:bookworm-slim
LABEL org.opencontainers.image.authors="DOMjudge team <team@domjudge.org>"

ENV DEBIAN_FRONTEND=noninteractive \
Expand All @@ -55,8 +63,10 @@ RUN apt update \
nginx php-cli php-fpm php-zip \
php-gd php-curl php-mysql php-json php-intl \
php-gmp php-xml php-mbstring php-ldap \
enscript lpr \
enscript \
printer-driver-all cups cups-pdf cups-client cups-bsd cups-filters \
ca-certificates python3-yaml python3-requests \
vim wget httpie \
&& rm -rf /var/lib/apt/lists/*

# Install composer
Expand Down
9 changes: 6 additions & 3 deletions docker/domserver/build.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/sh -eu

# Use venv to use latest Sphinx. 6.1.0 or higher is required to build DOMjudge docs.
. /venv/bin/activate

cd /domjudge-src/domjudge*
chown -R domjudge: .
# If we used a local source tarball, it might not have been built yet
sudo -u domjudge make dist
sudo -u domjudge ./configure -with-baseurl=http://localhost/
sudo -u domjudge sh -c '. /venv/bin/activate && make dist'
sudo -u domjudge ./configure -with-baseurl=http://dj.chipcie.ch.tudelft.nl/

# Passwords should not be included in the built image. We create empty files here to prevent passwords from being generated.
sudo -u domjudge touch etc/dbpasswords.secret etc/restapi.secret etc/symfony_app.secret etc/initial_admin_password.secret
Expand All @@ -25,5 +28,5 @@ then
rm /opt/domjudge/domserver/webapp/.env.local /opt/domjudge/domserver/webapp/.env.local.php
fi

sudo -u domjudge make docs
sudo -u domjudge sh -c '. /venv/bin/activate && make docs'
make install-docs
2 changes: 1 addition & 1 deletion docker/domserver/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ done

# Configure php

php_folder=$(echo "/etc/php/7."?"/")
php_folder=$(echo "/etc/php/8."?"/")
php_version=$(basename "$php_folder")

if [ ! -d "$php_folder" ]
Expand Down
Loading
Loading