summaryrefslogtreecommitdiff
path: root/Dockerfile
diff options
context:
space:
mode:
authorㄗㄠˋ ㄑㄧˊ <tsao-chi@the-lingo.org>2020-04-12 17:00:56 +0800
committerGitHub <noreply@github.com>2020-04-12 11:00:56 +0200
commitd7e706ac9df5e7cead3dd16f91b07bc0d417e234 (patch)
tree1dc8aca9d4582a9e21be22f97af0077208f9cbcf /Dockerfile
parentb55dd5d82f4fabca1b7cc9bea395c9d3fc4ac5a9 (diff)
downloadminetest-d7e706ac9df5e7cead3dd16f91b07bc0d417e234.tar.gz
minetest-d7e706ac9df5e7cead3dd16f91b07bc0d417e234.tar.bz2
minetest-d7e706ac9df5e7cead3dd16f91b07bc0d417e234.zip
Dockerfile: use alpine to reduce size (#9226)
* Dockerfile: use alpine to reduce size * Fix the UID & GID + alpine version + rights * Reduce the junk when we copy, only copy needed files * Build in the right cmake place & permit customize mtg version * Latest build fixes Co-authored-by: Loïc Blot <nerzhul@users.noreply.github.com>
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile68
1 files changed, 40 insertions, 28 deletions
diff --git a/Dockerfile b/Dockerfile
index 8c82f856c..3c41ce0f4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,32 +1,44 @@
-FROM debian:buster
-
-USER root
-RUN apt-get update -y && \
- apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev \
- libsqlite3-dev libcurl4-gnutls-dev zlib1g-dev libgmp-dev libjsoncpp-dev git
+FROM alpine:3.11
+
+ENV MINETEST_GAME_VERSION master
+
+COPY .git /usr/src/minetest/.git
+COPY CMakeLists.txt /usr/src/minetest/CMakeLists.txt
+COPY README.md /usr/src/minetest/README.md
+COPY minetest.conf.example /usr/src/minetest/minetest.conf.example
+COPY builtin /usr/src/minetest/builtin
+COPY cmake /usr/src/minetest/cmake
+COPY doc /usr/src/minetest/doc
+COPY fonts /usr/src/minetest/fonts
+COPY lib /usr/src/minetest/lib
+COPY misc /usr/src/minetest/misc
+COPY po /usr/src/minetest/po
+COPY src /usr/src/minetest/src
+COPY textures /usr/src/minetest/textures
+
+WORKDIR /usr/src/minetest
+
+RUN apk add --no-cache git build-base irrlicht-dev cmake bzip2-dev libpng-dev \
+ jpeg-dev libxxf86vm-dev mesa-dev sqlite-dev libogg-dev \
+ libvorbis-dev openal-soft-dev curl-dev freetype-dev zlib-dev \
+ gmp-dev jsoncpp-dev postgresql-dev && \
+ git clone --depth=1 -b ${MINETEST_GAME_VERSION} https://github.com/minetest/minetest_game.git ./games/minetest_game && \
+ rm -fr ./games/minetest_game/.git && \
+ mkdir build && \
+ cd build && \
+ cmake .. \
+ -DCMAKE_INSTALL_PREFIX=/usr/local \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DBUILD_SERVER=TRUE \
+ -DBUILD_CLIENT=FALSE && \
+ make -j2 && \
+ make install
-COPY . /usr/src/minetest
+FROM alpine:3.11
-RUN mkdir -p /usr/src/minetest/cmakebuild && cd /usr/src/minetest/cmakebuild && \
- cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release -DRUN_IN_PLACE=FALSE \
- -DBUILD_SERVER=TRUE \
- -DBUILD_CLIENT=FALSE \
- -DENABLE_SYSTEM_JSONCPP=1 \
- .. && \
- make -j2 && \
- rm -Rf ../games/minetest_game && git clone --depth 1 https://github.com/minetest/minetest_game ../games/minetest_game && \
- rm -Rf ../games/minetest_game/.git && \
- make install
-
-FROM debian:stretch
-
-USER root
-RUN groupadd minetest && useradd -m -g minetest -d /var/lib/minetest minetest && \
- apt-get update -y && \
- apt-get -y install libcurl3-gnutls libjsoncpp1 liblua5.1-0 libluajit-5.1-2 libpq5 libsqlite3-0 \
- libstdc++6 zlib1g libc6 && \
- apt-get clean && rm -rf /var/cache/apt/archives/* && \
- rm -rf /var/lib/apt/lists/*
+RUN apk add --no-cache sqlite-libs curl gmp libstdc++ libgcc libpq && \
+ adduser -D minetest --uid 30000 -h /var/lib/minetest && \
+ chown -R minetest:minetest /var/lib/minetest
WORKDIR /var/lib/minetest
@@ -34,7 +46,7 @@ COPY --from=0 /usr/local/share/minetest /usr/local/share/minetest
COPY --from=0 /usr/local/bin/minetestserver /usr/local/bin/minetestserver
COPY --from=0 /usr/local/share/doc/minetest/minetest.conf.example /etc/minetest/minetest.conf
-USER minetest
+USER minetest:minetest
EXPOSE 30000/udp