Skip to content

Commit 661765b

Browse files
committed
Decrease docker image size
Switch to the *-slim docker image as the base, don't include sandboxes twice in the final image and pass --no-install-recommends to apt.
1 parent 26498fa commit 661765b

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

Dockerfile

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM python:3.11 AS base
1+
FROM python:3.11-slim AS base
22

33
ENV PYTHONUNBUFFERED 1
44

55
#RUN dpkg --add-architecture i386
66
RUN apt-get update && \
7-
apt-get install -y \
7+
apt-get install --no-install-recommends -y \
88
git \
99
libpq-dev \
1010
postgresql-client \
@@ -16,9 +16,13 @@ RUN apt-get update && \
1616
texlive-lang-european \
1717
texlive-lang-czechslovak \
1818
texlive-pstricks \
19-
ghostscript \
2019
texlive-fonts-recommended \
20+
tex-gyre \
21+
ghostscript \
22+
make \
2123
gcc \
24+
g++ \
25+
libc6-dev \
2226
sudo \
2327
libstdc++6 \
2428
zlib1g \
@@ -28,7 +32,8 @@ RUN apt-get update && \
2832
python3-pip \
2933
nodejs \
3034
npm && \
31-
apt-get clean
35+
apt-get clean && \
36+
rm -rf /usr/share/doc/texlive*
3237

3338
# This is oioioi user linux uid. Setting it is useful in development.
3439
# By default we use an unused uid of 1234.
@@ -75,7 +80,7 @@ WORKDIR /sio2/deployment
7580
RUN mkdir -p /sio2/deployment/logs/{supervisor,runserver}
7681

7782
# The stage below is independent of base and can be built in parallel to optimize build time.
78-
FROM python:3.11 AS development-sandboxes
83+
FROM python:3.11-slim AS development-sandboxes
7984

8085
ENV DOWNLOAD_DIR=/sio2/sandboxes
8186
ENV MANIFEST_URL=https://downloads.sio2project.mimuw.edu.pl/sandboxes/Manifest
@@ -84,7 +89,7 @@ ENV MANIFEST_URL=https://downloads.sio2project.mimuw.edu.pl/sandboxes/Manifest
8489
ADD $MANIFEST_URL /sio2/Manifest
8590

8691
RUN apt-get update && \
87-
apt-get install -y curl wget bash && \
92+
apt-get install --no-install-recommends -y curl wget bash && \
8893
apt-get clean
8994

9095
COPY download_sandboxes.sh /download_sandboxes.sh
@@ -93,14 +98,19 @@ RUN chmod +x /download_sandboxes.sh
9398
# Run script to download sandbox data from the given Manifest.
9499
RUN ./download_sandboxes.sh -q -y -d $DOWNLOAD_DIR -m $MANIFEST_URL
95100

96-
FROM base AS development
97-
101+
# For production (or dev with filetracker): Upload sandboxes to built-in filetracker during build
102+
# For dev: The sandboxes will be re-uploaded to s3dedup at runtime via oioioi_init.sh
103+
FROM base AS base_with_sandboxes
98104
COPY --from=development-sandboxes /sio2/sandboxes /sio2/sandboxes
99-
RUN chmod +x /sio2/oioioi/download_sandboxes.sh
100105

101-
# For production: Upload sandboxes to built-in filetracker during build
102-
# For dev: These will be re-uploaded to s3dedup at runtime via oioioi_init.sh
103-
RUN ./manage.py supervisor > /dev/null --daemonize --nolaunch=uwsgi && \
106+
FROM base_with_sandboxes AS base_with_populated_filetracker
107+
RUN ./manage.py supervisor > /dev/null --daemonize \
108+
--nolaunch={uwsgi,unpackmgr,evalmgr,rankingsd,mailnotifyd,sioworkersd,receive_from_workers} && \
104109
/sio2/oioioi/wait-for-it.sh -t 60 "127.0.0.1:9999" && \
105110
./manage.py upload_sandboxes_to_filetracker -d /sio2/sandboxes && \
106111
./manage.py supervisor stop all
112+
113+
FROM base_with_sandboxes AS development
114+
115+
FROM base AS development_filetracker
116+
COPY --from=base_with_populated_filetracker /sio2/deployment/media /sio2/deployment/media

0 commit comments

Comments
 (0)