From f35d23674e68b8e86d748e8555b7c48f44e5b526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Andr=C3=A9=20Damas?= Date: Mon, 2 Jun 2025 23:37:27 +0000 Subject: [PATCH] Make docker image smaller --- Dockerfile | 15 +++++++++++++-- start.sh | 6 +++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0cc0e4e..6bcf0a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:latest +FROM alpine:latest AS builder ENV OPENTTD_JGR_VERSION=0.65.3 @@ -26,18 +26,29 @@ WORKDIR /openttd RUN git clone --depth 1 --branch jgrpp-$OPENTTD_JGR_VERSION https://github.com/JGRennison/OpenTTD-patches.git source -# Build the source WORKDIR /openttd/source RUN mkdir build && cd build && \ cmake .. -DCMAKE_BUILD_TYPE=Release && \ make -j$(nproc) +FROM alpine:latest + WORKDIR /openttd + +COPY --from=builder /openttd/source/build /openttd + RUN mkdir -p /root/.openttd/baseset && \ wget -q https://cdn.openttd.org/opengfx-releases/7.1/opengfx-7.1-all.zip && \ unzip opengfx-7.1-all.zip -d /root/.openttd/baseset && \ rm opengfx-7.1-all.zip +RUN apk add --no-cache \ + sdl2-dev \ + fontconfig-dev \ + icu-dev \ + lzo-dev + COPY start.sh /start.sh RUN chmod +x /start.sh + CMD ["/start.sh"] diff --git a/start.sh b/start.sh index ede2521..1401b56 100644 --- a/start.sh +++ b/start.sh @@ -1,10 +1,10 @@ -#!/bin/bash +#!/bin/sh SAVE_FILE="/root/.openttd/save/autosave/latest.sav" if [ -f "$SAVE_FILE" ]; then echo "Loading savegame: $SAVE_FILE" - exec /openttd/source/build/openttd -D -g autosave/latest.sav + exec /openttd/openttd -D -g autosave/latest.sav else echo "No savegame found. Starting new game." - exec /openttd/source/build/openttd -D + exec /openttd/openttd -D fi