Skip to content

Commit b6c8982

Browse files
authored
Simplify & optimize Dockerfile for building server image, fix openssl linker errors (#821)
* Simplify Dockerfile for server image, fix openssl linker errors Dockerfile -> Dockerfile.multiarch * Leave single Dockerfile
1 parent 85d1bd6 commit b6c8982

File tree

2 files changed

+25
-45
lines changed

2 files changed

+25
-45
lines changed

Dockerfile

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,41 @@
1-
FROM tiltedphoques/multiarch-builder:latest as builder
1+
# Building the server:
2+
# x64: $ docker build -t imagename .
3+
# arm64: $ docker build --platform linux/arm64 -t imagename .
4+
# multi-platform (build and push):
5+
# $ docker buildx create --name st-server-multiarch --use
6+
# $ docker buildx build --platform linux/amd64,linux/arm64 -t imagename:tag --push .
27

3-
ARG REPO=https://github.com/tiltedphoques/TiltedEvolution.git
4-
ARG BRANCH=master
5-
6-
WORKDIR /home/builder
8+
FROM debian:12 AS builder
79

10+
ENV DEBIAN_FRONTEND=noninteractive
811
ENV XMAKE_ROOT=y
912
SHELL ["/bin/bash", "-c"]
1013

11-
RUN source ~/.xmake/profile && git clone --recursive -b ${BRANCH} ${REPO} ./str && cd str && xmake config -m release -y && xmake -y && xmake install -o package -y
12-
13-
14-
# Building for x86_64
15-
FROM builder as amd64builder
14+
# Get packages and xmake
1615

17-
RUN cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30 /home/builder/libstdc++.so.6 2>/dev/null || :
16+
RUN apt-get update && apt-get install -y --no-install-recommends build-essential curl pkg-config git ca-certificates unzip libssl-dev && \
17+
rm -rf /var/lib/apt/lists/* && \
18+
curl -fsSL https://xmake.io/shget.text | bash
1819

20+
# Copy source and build
1921

20-
# Building for arm64/v8
21-
FROM builder as arm64builder
22+
WORKDIR /src
23+
COPY . /src
2224

23-
RUN cp /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.30 /home/builder/libstdc++.so.6 2>/dev/null || :
25+
RUN source ~/.xmake/profile && \
26+
xmake config -y -m release && xmake -y && xmake install -y -o package
2427

28+
# Actual server runtime image; distroless for small footprint
2529

26-
# Intermediate image that has the library specific to our $TARGETARCH
27-
FROM ${TARGETARCH}builder as intermediate
28-
# If a user has built without buildx, attempt to save them
29-
RUN if [ "${TARGETARCH}" = "" ]; then export LIBFILE="/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30"; if [ ! -e ${LIBFILE} ]; then export LIBFILE=/usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.30; fi ; cp ${LIBFILE} /home/builder/libstdc++.so.6; fi
30+
FROM gcr.io/distroless/cc-debian12 AS runtime
3031

32+
WORKDIR /st-server
3133

32-
# Build actual server image
33-
FROM ubuntu:22.04
34+
COPY --from=builder \
35+
/src/package/lib/libSTServer.so \
36+
/src/package/bin/crashpad_handler \
37+
/src/package/bin/SkyrimTogetherServer \
38+
/st-server/
3439

35-
COPY --from=intermediate /home/builder/str/package/lib/libSTServer.so /home/server/libSTServer.so
36-
COPY --from=intermediate /home/builder/str/package/bin/crashpad_handler /home/server/crashpad_handler
37-
COPY --from=intermediate /home/builder/str/package/bin/SkyrimTogetherServer /home/server/SkyrimTogetherServer
38-
39-
COPY --from=intermediate /home/builder/libstdc++.so.6 /home/server/libstdc++.so.6
40-
41-
WORKDIR /home/server
4240
ENTRYPOINT ["./SkyrimTogetherServer"]
43-
4441
EXPOSE 10578/udp

Dockerfile.builder

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)