Add support for multi-platform builds with docker buildx
- also added docs
This commit is contained in:
parent
d85efbad60
commit
108b19970b
4 changed files with 33 additions and 20 deletions
|
|
@ -12,4 +12,4 @@
|
||||||
|
|
||||||
# but exclude build artifacts
|
# but exclude build artifacts
|
||||||
*/bin/
|
*/bin/
|
||||||
*/obj/
|
*/obj/
|
||||||
|
|
|
||||||
38
Dockerfile
38
Dockerfile
|
|
@ -1,32 +1,32 @@
|
||||||
|
FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:6.0 AS builder
|
||||||
|
|
||||||
# Docker Instructions
|
ARG TARGETPLATFORM
|
||||||
# Build Image:
|
|
||||||
# docker build -t tshock .
|
|
||||||
# and run:
|
|
||||||
# docker run -p 7777:7777 -p 7878:7878 \
|
|
||||||
# -v <save path>:/tshock \
|
|
||||||
# -v <world path>:/worlds \
|
|
||||||
# -v <plugin path>:/plugins \
|
|
||||||
# --rm -it tshock -world /worlds/<world file> <flags>
|
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS builder
|
|
||||||
|
|
||||||
ARG ARCH=linux-x64
|
|
||||||
|
|
||||||
# Copy build context
|
# Copy build context
|
||||||
WORKDIR /TShock
|
WORKDIR /TShock
|
||||||
COPY . ./
|
COPY . ./
|
||||||
|
|
||||||
# Build and package release
|
# Build and package release based on target architecture
|
||||||
RUN dotnet build
|
RUN dotnet build -v m
|
||||||
WORKDIR /TShock/TShockLauncher
|
WORKDIR /TShock/TShockLauncher
|
||||||
RUN dotnet publish -o output/ -r ${ARCH} -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false
|
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
|
# Runtime image
|
||||||
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS runner
|
FROM --platform=${TARGETPLATFORM} mcr.microsoft.com/dotnet/runtime:6.0 AS runner
|
||||||
WORKDIR /server
|
WORKDIR /server
|
||||||
COPY --from=builder /TShock/TShockLauncher/output ./
|
COPY --from=builder /TShock/TShockLauncher/output ./
|
||||||
RUN mkdir -p /tshock /worlds /plugins
|
|
||||||
|
|
||||||
VOLUME ["/tshock", "/worlds", "/plugins"]
|
VOLUME ["/tshock", "/worlds", "/plugins"]
|
||||||
EXPOSE 7777 7878
|
EXPOSE 7777 7878
|
||||||
|
|
@ -38,4 +38,4 @@ ENTRYPOINT [ \
|
||||||
"-crashdir", "/tshock/crashes", \
|
"-crashdir", "/tshock/crashes", \
|
||||||
"-worldselectpath", "/worlds", \
|
"-worldselectpath", "/worlds", \
|
||||||
"-additionalplugins", "/plugins" \
|
"-additionalplugins", "/plugins" \
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
* [☕️⚡️ TShock documentation home](/)
|
* [☕️⚡️ TShock documentation home](/)
|
||||||
* [Changelog](/changelog.md)
|
* [Changelog](/changelog.md)
|
||||||
* [Command line parameters](/command-line-parameters.md)
|
* [Command line parameters](/command-line-parameters.md)
|
||||||
|
* [Docker Setup](/docker.md)
|
||||||
|
|
||||||
* Subsystems
|
* Subsystems
|
||||||
* [Tile providers](/tile-providers.md)
|
* [Tile providers](/tile-providers.md)
|
||||||
|
|
|
||||||
12
docs/docker.md
Normal file
12
docs/docker.md
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Docker Setup
|
||||||
|
|
||||||
|
## Build Image:
|
||||||
|
`docker build -t tshock .`
|
||||||
|
## and run:
|
||||||
|
```bash
|
||||||
|
docker run -p 7777:7777 -p 7878:7878 \
|
||||||
|
-v <save path>:/tshock \
|
||||||
|
-v <world path>:/worlds \
|
||||||
|
-v <plugin path>:/plugins \
|
||||||
|
--rm -it tshock [-world /worlds/<world file>] <other cmdline flags>
|
||||||
|
```
|
||||||
Loading…
Add table
Add a link
Reference in a new issue