|
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 . |
2 | 7 |
|
3 | | -ARG REPO=https://github.com/tiltedphoques/TiltedEvolution.git |
4 | | -ARG BRANCH=master |
5 | | - |
6 | | -WORKDIR /home/builder |
| 8 | +FROM debian:12 AS builder |
7 | 9 |
|
| 10 | +ENV DEBIAN_FRONTEND=noninteractive |
8 | 11 | ENV XMAKE_ROOT=y |
9 | 12 | SHELL ["/bin/bash", "-c"] |
10 | 13 |
|
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 |
16 | 15 |
|
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 |
18 | 19 |
|
| 20 | +# Copy source and build |
19 | 21 |
|
20 | | -# Building for arm64/v8 |
21 | | -FROM builder as arm64builder |
| 22 | +WORKDIR /src |
| 23 | +COPY . /src |
22 | 24 |
|
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 |
24 | 27 |
|
| 28 | +# Actual server runtime image; distroless for small footprint |
25 | 29 |
|
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 |
30 | 31 |
|
| 32 | +WORKDIR /st-server |
31 | 33 |
|
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/ |
34 | 39 |
|
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 |
42 | 40 | ENTRYPOINT ["./SkyrimTogetherServer"] |
43 | | - |
44 | 41 | EXPOSE 10578/udp |
0 commit comments