-
-
Notifications
You must be signed in to change notification settings - Fork 382
/
Dockerfile
47 lines (39 loc) · 1.32 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# TARGETPLATFORM and BUILDPLATFORM are automatically filled in by Docker buildx.
# They should not be set in the global scope manually.
FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:6.0 AS builder
# Copy build context
WORKDIR /TShock
COPY . ./
# Build and package release based on target architecture
RUN dotnet build -v m
WORKDIR /TShock/TShockLauncher
# Make TARGETPLATFORM available to the container.
ARG TARGETPLATFORM
RUN \
case "${TARGETPLATFORM}" in \
"linux/amd64") export ARCH="linux-x64" \
;; \
"linux/arm64") export ARCH="linux-arm64" \
;; \
"linux/arm/v7") export ARCH="linux-arm" \
;; \
"windows/amd64") export ARCH="win-x64" \
;; \
*) echo "Error: Unsupported platform ${TARGETPLATFORM}" && exit 1 \
;; \
esac && \
dotnet publish -o output/ -r "${ARCH}" -v m -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false
# Runtime image
FROM --platform=${TARGETPLATFORM} mcr.microsoft.com/dotnet/runtime:6.0 AS runner
WORKDIR /server
COPY --from=builder /TShock/TShockLauncher/output ./
VOLUME ["/tshock", "/worlds", "/plugins"]
EXPOSE 7777 7878
ENTRYPOINT [ \
"./TShock.Server", \
"-configpath", "/tshock", \
"-logpath", "/tshock/logs", \
"-crashdir", "/tshock/crashes", \
"-worldselectpath", "/worlds", \
"-additionalplugins", "/plugins" \
]