Skip to content

Commit

Permalink
build: use judging-containers
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangt2333 committed Jun 2, 2024
1 parent ca4ed37 commit 1ede90a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 81 deletions.
84 changes: 36 additions & 48 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM ubuntu:18.04 as basic
ARG UBUNTU_VERSION=18.04
FROM ubuntu:${UBUNTU_VERSION} as basic
# metadata
LABEL maintainer="SDUOJ-Team"
ENV JUDGER_TAG="default"

# fix encoding
ENV LANG=C.UTF-8 \
Expand All @@ -11,65 +14,50 @@ ENV LANG=C.UTF-8 \
PYTHONDONTWRITEBYTECODE=1

# install runtime dependencies
RUN --mount=type=bind,source=docker/substitute-apt-sources.sh,target=substitute-apt-sources.sh \
apt-get update -qq \
ARG ENABLE_REPLACE_APT_SOURCES=false
RUN --mount=type=bind,source=docker/replace-apt-sources.sh,target=replace-apt-sources.sh \
bash replace-apt-sources.sh ${ENABLE_REPLACE_APT_SOURCES} \
&& apt-get update -qq \
&& apt-get install -y -qq --no-install-recommends \
ca-certificates tzdata \
# substitute apt sources (optional)
# && bash substitute-apt-sources.sh \
# && apt-get update -qq \
# install OS software
&& apt-get install -y -qq --no-install-recommends \
make=4.1-9.1ubuntu1 dosbox=0.74-4.3 \
cmake sudo git unzip wget curl host dos2unix vim \
libseccomp-dev libseccomp2 seccomp build-essential \
sudo git unzip wget curl host dos2unix vim \
make=4.1-9.1ubuntu1 cmake \
# install dosbox for Assembly Course
dosbox=0.74-4.3 \
&& apt-get clean autoclean \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -f /var/cache/apt/archives/*.deb

# ---------------------------------------------
FROM continuumio/miniconda3 as py-builder

RUN for PYTHON_VERSION in 3.6 3.11; do \
conda create --prefix /opt/python/${PYTHON_VERSION} python=${PYTHON_VERSION} -y -q \
&& /opt/python/${PYTHON_VERSION}/bin/python -m pip install --upgrade pip \
; done

RUN --mount=type=bind,source=docker/install-pypy.sh,target=install-pypy.sh \
bash install-pypy.sh \
&& rm -rf /opt/conda \
&& ls -l /opt
# ---------------------------------------------
FROM basic

# install JDK(s)
ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:8 $JAVA_HOME ${JAVA_HOME}8
COPY --from=eclipse-temurin:17 $JAVA_HOME ${JAVA_HOME}17
# install JDK
COPY --from=eclipse-temurin:8 /opt/java/openjdk /opt/java/openjdk8
COPY --from=eclipse-temurin:17 /opt/java/openjdk /opt/java/openjdk17
COPY --from=eclipse-temurin:21 /opt/java/openjdk /opt/java/openjdk21
# set the default JDK to JDK17
ENV JAVA_HOME=/opt/java/openjdk17
ENV PATH="${JAVA_HOME}/bin:${PATH}"
# install Python
COPY --from=ghcr.io/sduoj/judging-containers:python-3.6 /opt/ /opt/
COPY --from=ghcr.io/sduoj/judging-containers:python-3.11 /opt/ /opt/
COPY --from=ghcr.io/sduoj/judging-containers:python-3.12-csp /opt/ /opt/
# install PyPy
COPY --from=ghcr.io/sduoj/judging-containers:pypy-3.10-v7.3.15 /opt/ /opt/
# install GCC
COPY --from=ghcr.io/sduoj/judging-containers:ubuntu-18.04_gcc-7.5.0 /opt/ /opt/
COPY --from=ghcr.io/sduoj/judging-containers:ubuntu-18.04_gcc-13.2.0 /opt/ /opt/
# install Rust
COPY --from=ghcr.io/sduoj/judging-containers:ubuntu-18.04_rust-1.78.0 /opt/ /opt/
# install sduoj-sandbox
COPY --from=ghcr.io/sduoj/judging-containers:ubuntu-18.04_sduoj-sandbox /opt/ /opt/
# install docker-compose-wait
COPY --from=ghcr.io/sduoj/docker-compose-wait:latest /wait /wait

# install Python(s)
COPY --from=py-builder /opt/ /opt/
RUN ln -s /opt/python/3.11/bin/python /usr/bin/python3 \
&& ln -s /opt/python/3.11/bin/python /usr/bin/python3.11 \
&& ln -s /opt/python/3.6/bin/python /usr/bin/python3.6 \
&& ln -s /opt/pypy/3.10/bin/pypy /usr/bin/pypy3 \
&& ln -s /opt/pypy/3.10/bin/pypy /usr/bin/pypy3.10

# download docker-compose-wait
COPY --from=sduoj/docker-compose-wait:latest /wait /wait

# compile and install sduoj-sandbox
# configure the environment
RUN mkdir -p /sduoj \
&& wget -q -O /sduoj/sandbox.zip https://codeload.github.com/SDUOJ/sduoj-sandbox/zip/master \
&& unzip -o -q -d /sduoj /sduoj/sandbox.zip \
&& rm /sduoj/sandbox.zip \
&& cd /sduoj/sduoj-sandbox* \
&& make \
&& make install
&& ln -s /opt/sduoj-sandbox/bin/sandbox /usr/bin/sandbox \
&& ln -s /opt/python/3.11/bin/python /usr/bin/python3 \
&& ln -s /opt/gcc/7.5.0/bin/gcc /usr/bin/gcc \
&& ln -s /opt/gcc/7.5.0/bin/g++ /usr/bin/g++

# copy sduoj-judger
COPY sduoj-judger-service/build/libs/ /sduoj/
Expand Down
33 changes: 0 additions & 33 deletions docker/install-pypy.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@

set -eux

# Check if the argument is provided
if [ $# -ne 1 ]; then
echo "Usage: $0 true|false"
exit 0
fi

if [ $1 == "true" ]; then
cat << "EOF" > /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
EOF
fi

0 comments on commit 1ede90a

Please sign in to comment.