diff --git a/docker/ci.Dockerfile b/docker/ci.Dockerfile index 7b020290..2916a5c5 100644 --- a/docker/ci.Dockerfile +++ b/docker/ci.Dockerfile @@ -1,33 +1,17 @@ -FROM sbtscala/scala-sbt:eclipse-temurin-jammy-21.0.2_13_1.9.9_3.4.0 - -# Install mongodb -# https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/ -RUN apt-get update \ - && apt-get install gnupg curl -y \ - && curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \ - gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \ - --dearmor \ - && echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list \ - && apt-get update \ - && apt-get install -y mongodb-org \ - && apt-get clean \ - && mkdir -p /data/db - -# Install redis -# https://redis.io/docs/install/install-redis/install-redis-on-linux/ -RUN apt install lsb-release curl gpg -y \ - && curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg \ - && echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list \ - && apt-get update \ - && apt-get install redis -y \ - && apt-get clean +################################################################################## +FROM mongo:7-jammy as dbbuilder + +RUN apt update && apt install -y git python3-pip curl +RUN pip3 install pymongo requests +RUN curl -L https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_x64_linux_hotspot_21.0.2_13.tar.gz | tar xzf - && mv jdk-21* /jdk-21 +ENV PATH=/jdk-21/bin:$PATH RUN git clone --depth 1 https://github.com/lichess-org/lila-db-seed /lila-db-seed WORKDIR /lila-db-seed -RUN apt install python3-pip -y \ - && pip3 install pymongo requests -RUN mongod --fork --logpath /var/log/mongod.log \ - && ./spamdb/spamdb.py \ + +RUN mkdir /seeded +RUN mongod --fork --logpath /var/log/mongodb/mongod.log --dbpath /seeded \ + && ./spamdb/spamdb.py \ --drop-db \ --password=password \ --su-password=password \ @@ -35,15 +19,34 @@ RUN mongod --fork --logpath /var/log/mongod.log \ --coaches \ --tokens -## Pre-install dependencies for Berserk client -RUN pip3 install berserk pytest +################################################################################## +FROM sbtscala/scala-sbt:eclipse-temurin-jammy-21.0.2_13_1.9.9_3.4.0 as lilabuilder -RUN git clone --depth 1 https://github.com/lichess-org/lila.git /lila -WORKDIR /lila +RUN apt update && apt install -y git -COPY conf/ci.conf /lila/conf/application.conf +RUN mkdir /lila +WORKDIR /lila +RUN git clone --depth 1 https://github.com/lichess-org/lila.git . +COPY conf/ci.conf ./conf/application.conf RUN ./lila stage -CMD mongod --fork --logpath /var/log/mongod.log \ +################################################################################## +FROM mongo:7-jammy + +RUN apt update && apt install -y curl redis python3-pip && apt clean +RUN pip3 install berserk pytest + +COPY --from=dbbuilder /seeded /seeded +COPY --from=dbbuilder /jdk-21 /jdk-21 +COPY --from=lilabuilder /lila/target /lila/target +COPY --from=lilabuilder /lila/public /lila/public +COPY --from=lilabuilder /lila/conf /lila/conf + +ENV JAVA_HOME=/jdk-21 +ENV PATH=/jdk-21/bin:$PATH +ENV LANG=C.utf8 + +WORKDIR /lila +CMD mongod --fork --logpath /var/log/mongodb/mongod.log --dbpath /seeded \ && redis-server --daemonize yes \ && JAVA_OPTS="-Xms4g -Xmx4g" ./target/universal/stage/bin/lila -Dconfig.file="/lila/conf/application.conf" -Dlogger.file="/lila/conf/logger.dev.xml" diff --git a/docs/ci-testing.md b/docs/ci-testing.md new file mode 100644 index 00000000..ff52337d --- /dev/null +++ b/docs/ci-testing.md @@ -0,0 +1,10 @@ +## Testing the CI image build locally + +```bash +docker build -t lila-ci -f docker/ci.Dockerfile . +docker run -it --rm -p 9663:9663 lila-ci +``` + +```bash +curl localhost:9663/api/user/lichess +```