forked from sio2project/oioioi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
119 lines (94 loc) · 3.63 KB
/
Dockerfile
File metadata and controls
119 lines (94 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
FROM ghcr.io/astral-sh/uv:python3.11-trixie AS base
ENV PYTHONUNBUFFERED=1
#RUN dpkg --add-architecture i386
RUN apt-get update && \
apt-get install --no-install-recommends -y \
git \
libpq-dev \
postgresql-client \
libdb-dev \
texlive-latex-base \
texlive-lang-polish \
texlive-latex-extra \
texlive-lang-german \
texlive-lang-european \
texlive-lang-czechslovak \
texlive-pstricks \
texlive-fonts-recommended \
tex-gyre \
ghostscript \
make \
gcc \
g++ \
libc6-dev \
sudo \
libstdc++6 \
zlib1g \
sox \
flite \
locales \
nodejs \
npm && \
apt-get clean && \
rm -rf /usr/share/doc/texlive*
# This is oioioi user linux uid. Setting it is useful in development.
# By default we use an unused uid of 1234.
# This is placed here to avoid redownloading package on uid change
ARG oioioi_uid=1234
# Bash as shell, setup folders, create oioioi user
RUN rm /bin/sh && ln -s /bin/bash /bin/sh && \
mkdir -pv /sio2/oioioi && \
mkdir -pv /sio2/sandboxes && \
useradd -U oioioi -m -d /home/oioioi/ -u $oioioi_uid && \
echo "oioioi ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
chown -R oioioi:oioioi /sio2
# Modify locale
RUN sed -i -e "s/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/" /etc/locale.gen && \
locale-gen
# Installing python dependencies
USER oioioi
ENV UV_NO_CACHE=1
ENV VIRTUAL_ENV=/home/oioioi/venv
RUN uv venv $VIRTUAL_ENV
# The python executable from the venv must have priority over the system one.
ENV PATH=$VIRTUAL_ENV/bin/:$PATH
ENV BERKELEYDB_DIR=/usr
RUN uv pip install psycopg2-binary twisted uwsgi
RUN uv pip install bsddb3==6.2.7
WORKDIR /sio2/oioioi
COPY --chown=oioioi:oioioi . ./
RUN uv pip install -r requirements.txt filetracker[server]
RUN uv pip install -r requirements_static.txt
# Installing node dependencies
ENV PATH=$PATH:/sio2/oioioi/node_modules/.bin
RUN npm ci
RUN npm run build
RUN oioioi-create-config /sio2/deployment
WORKDIR /sio2/deployment
RUN mkdir -p /sio2/deployment/logs/{supervisor,runserver}
# The stage below is independent of base and can be built in parallel to optimize build time.
FROM python:3.11-slim AS development-sandboxes
ENV DOWNLOAD_DIR=/sio2/sandboxes
ENV MANIFEST_URL=https://downloads.sio2project.mimuw.edu.pl/sandboxes/Manifest
# Download the file and invalidate the cache if the Manifest checksum changes.
ADD $MANIFEST_URL /sio2/Manifest
RUN apt-get update && \
apt-get install --no-install-recommends -y curl wget bash && \
apt-get clean
COPY download_sandboxes.sh /download_sandboxes.sh
RUN chmod +x /download_sandboxes.sh
# Run script to download sandbox data from the given Manifest.
RUN ./download_sandboxes.sh -q -y -d $DOWNLOAD_DIR -m $MANIFEST_URL
# For production (or dev with filetracker): Upload sandboxes to built-in filetracker during build
# For dev: The sandboxes will be re-uploaded to s3dedup at runtime via oioioi_init.sh
FROM base AS base_with_sandboxes
COPY --from=development-sandboxes /sio2/sandboxes /sio2/sandboxes
FROM base_with_sandboxes AS base_with_populated_filetracker
RUN ./manage.py supervisor > /dev/null --daemonize \
--nolaunch={uwsgi,unpackmgr,evalmgr,rankingsd,mailnotifyd,sioworkersd,receive_from_workers} && \
/sio2/oioioi/wait-for-it.sh -t 60 "127.0.0.1:9999" && \
./manage.py upload_sandboxes_to_filetracker -d /sio2/sandboxes && \
./manage.py supervisor stop all
FROM base_with_sandboxes AS development
FROM base AS development_filetracker
COPY --from=base_with_populated_filetracker /sio2/deployment/media /sio2/deployment/media