Dockerfile: refactoring and addition of entrypoint (#12939)

Previously source files were copied first, then build dependencies were
installed, then libraries cloned and built.
This was reordered to be:
1. install dependencies
2. clone and build libraries
3. Pull in minetest source and minetest_game
4. Build minetest

In addition the peristent volumes are now declared.
Also an entrypoint added making it possible to append command line
parameters.
This commit is contained in:
Tamara Schmitz 2022-11-08 16:34:58 +01:00 committed by GitHub
parent 322c8cf270
commit 6191bafcad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,9 +1,26 @@
ARG DOCKER_IMAGE=alpine:3.14 ARG DOCKER_IMAGE=alpine:3.16
FROM $DOCKER_IMAGE AS builder FROM $DOCKER_IMAGE AS builder
ENV MINETEST_GAME_VERSION master ENV MINETEST_GAME_VERSION master
ENV IRRLICHT_VERSION master ENV IRRLICHT_VERSION master
RUN apk add --no-cache git build-base cmake sqlite-dev curl-dev zlib-dev zstd-dev \
gmp-dev jsoncpp-dev postgresql-dev ninja luajit-dev ca-certificates
WORKDIR /usr/src/
RUN git clone --recursive https://github.com/jupp0r/prometheus-cpp/ && \
cd prometheus-cpp && \
cmake -B build \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_TESTING=0 \
-GNinja && \
cmake --build build && \
cmake --install build
RUN git clone --depth=1 https://github.com/minetest/irrlicht/ -b ${IRRLICHT_VERSION} && \
cp -r irrlicht/include /usr/include/irrlichtmt
COPY .git /usr/src/minetest/.git COPY .git /usr/src/minetest/.git
COPY CMakeLists.txt /usr/src/minetest/CMakeLists.txt COPY CMakeLists.txt /usr/src/minetest/CMakeLists.txt
COPY README.md /usr/src/minetest/README.md COPY README.md /usr/src/minetest/README.md
@ -19,28 +36,9 @@ COPY src /usr/src/minetest/src
COPY textures /usr/src/minetest/textures COPY textures /usr/src/minetest/textures
WORKDIR /usr/src/minetest WORKDIR /usr/src/minetest
RUN git clone --depth=1 -b ${MINETEST_GAME_VERSION} https://github.com/minetest/minetest_game.git ./games/minetest_game && \
RUN apk add --no-cache git build-base cmake sqlite-dev curl-dev zlib-dev zstd-dev \ rm -fr ./games/minetest_game/.git && \
gmp-dev jsoncpp-dev postgresql-dev ninja luajit-dev ca-certificates && \
git clone --depth=1 -b ${MINETEST_GAME_VERSION} https://github.com/minetest/minetest_game.git ./games/minetest_game && \
rm -fr ./games/minetest_game/.git
WORKDIR /usr/src/
RUN git clone --recursive https://github.com/jupp0r/prometheus-cpp/ && \
cd prometheus-cpp && \
cmake -B build \ cmake -B build \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_TESTING=0 \
-GNinja && \
cmake --build build && \
cmake --install build
RUN git clone --depth=1 https://github.com/minetest/irrlicht/ -b ${IRRLICHT_VERSION} && \
cp -r irrlicht/include /usr/include/irrlichtmt
WORKDIR /usr/src/minetest
RUN cmake -B build \
-DCMAKE_INSTALL_PREFIX=/usr/local \ -DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DBUILD_SERVER=TRUE \ -DBUILD_SERVER=TRUE \
@ -51,7 +49,7 @@ RUN cmake -B build \
cmake --build build && \ cmake --build build && \
cmake --install build cmake --install build
ARG DOCKER_IMAGE=alpine:3.14 ARG DOCKER_IMAGE=alpine:3.16
FROM $DOCKER_IMAGE AS runtime FROM $DOCKER_IMAGE AS runtime
RUN apk add --no-cache sqlite-libs curl gmp libstdc++ libgcc libpq luajit jsoncpp zstd-libs && \ RUN apk add --no-cache sqlite-libs curl gmp libstdc++ libgcc libpq luajit jsoncpp zstd-libs && \
@ -67,5 +65,7 @@ COPY --from=builder /usr/local/share/doc/minetest/minetest.conf.example /etc/min
USER minetest:minetest USER minetest:minetest
EXPOSE 30000/udp 30000/tcp EXPOSE 30000/udp 30000/tcp
VOLUME /var/lib/minetest/ /etc/minetest/
CMD ["/usr/local/bin/minetestserver", "--config", "/etc/minetest/minetest.conf"] ENTRYPOINT ["/usr/local/bin/minetestserver"]
CMD ["--config", "/etc/minetest/minetest.conf"]