Skip to content

Commit

Permalink
Combine Docker RUN statements to decrease image sizes (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
fitztrev authored Oct 14, 2024
1 parent 3b1b725 commit eba51e5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 26 deletions.
7 changes: 5 additions & 2 deletions docker/bbpPairings.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM ubuntu:focal

RUN apt-get update && \
apt-get install --yes git make g++ && \
apt-get clean
apt-get install --yes \
g++ \
git \
make \
&& apt-get clean

WORKDIR /mnt
26 changes: 18 additions & 8 deletions docker/ci.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ FROM node:22-bookworm AS node
COPY repos/lila /lila
COPY conf/ci.conf /lila/conf/application.conf
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
RUN corepack enable
RUN /lila/ui/build --clean-build --debug
RUN corepack enable \
&& /lila/ui/build --clean-build --debug

##################################################################################
FROM mongo:7-jammy AS dbbuilder

RUN apt update && apt install -y python3-pip python3-venv curl && apt clean
RUN apt update \
&& apt install -y \
curl \
python3-pip \
python3-venv \
&& apt clean

ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:21-jdk $JAVA_HOME $JAVA_HOME
Expand All @@ -19,9 +24,9 @@ ENV PATH="${JAVA_HOME}/bin:${PATH}"
COPY repos/lila-db-seed /lila-db-seed
WORKDIR /lila-db-seed

RUN mkdir /seeded
RUN mongod --fork --logpath /var/log/mongodb/mongod.log --dbpath /seeded \
&& ./spamdb/spamdb.py \
RUN mkdir /seeded \
&& mongod --fork --logpath /var/log/mongodb/mongod.log --dbpath /seeded \
&& ./spamdb/spamdb.py \
--drop-db \
--password=password \
--su-password=password \
Expand All @@ -46,8 +51,13 @@ RUN ./lila.sh stage
##################################################################################
FROM mongo:7-jammy

RUN apt update && apt install -y curl redis python3-pip && apt clean
RUN pip3 install berserk pytest
RUN apt update \
&& apt install -y \
curl \
python3-pip \
redis \
&& apt clean \
&& pip3 install berserk pytest

COPY --from=dbbuilder /seeded /seeded
COPY --from=lilawsbuilder /lila-ws/target /lila-ws/target
Expand Down
8 changes: 6 additions & 2 deletions docker/python.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ FROM eclipse-temurin:22.0.2_9-jdk-alpine

COPY --from=python:3.12.6-alpine3.20 / /

RUN pip install --upgrade pip
RUN pip install berserk pymongo requests termcolor
RUN pip install --upgrade pip \
&& pip install \
berserk \
pymongo \
requests \
termcolor

WORKDIR /lila-db-seed
26 changes: 12 additions & 14 deletions docker/ui.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
FROM node:22.9.0-bookworm-slim

USER root

RUN apt update && apt install -y git && apt clean

RUN git config --global --add safe.directory /chessground
RUN git config --global --add safe.directory /lila
RUN git config --global --add safe.directory /pgn-viewer

ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
RUN corepack enable

RUN pnpm config set store-dir /.pnpm-store

# needed for ui, chessground images
RUN mkdir -p /.cache && chmod -R 777 /.cache
# needed for api_docs
RUN mkdir -p /.npm && chmod -R 777 /.npm
RUN apt update \
&& apt install -y git \
&& apt clean \
&& git config --global --add safe.directory /chessground \
&& git config --global --add safe.directory /lila \
&& git config --global --add safe.directory /pgn-viewer \
&& corepack enable \
&& pnpm config set store-dir /.pnpm-store \
# needed for ui, chessground images
&& mkdir -p /.cache && chmod -R 777 /.cache \
# needed for api_docs
&& mkdir -p /.npm && chmod -R 777 /.npm

ARG USER_ID
ARG GROUP_ID
Expand Down

0 comments on commit eba51e5

Please sign in to comment.