Finish up docker docs and fix docker non-buildx builds
This commit is contained in:
parent
108b19970b
commit
298f277bf0
2 changed files with 55 additions and 18 deletions
26
Dockerfile
26
Dockerfile
|
|
@ -1,3 +1,6 @@
|
||||||
|
ARG TARGETPLATFORM=linux/amd64
|
||||||
|
ARG BUILDPLATFORM=${TARGETPLATFORM}
|
||||||
|
|
||||||
FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:6.0 AS builder
|
FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:6.0 AS builder
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
|
|
@ -9,17 +12,18 @@ COPY . ./
|
||||||
# Build and package release based on target architecture
|
# Build and package release based on target architecture
|
||||||
RUN dotnet build -v m
|
RUN dotnet build -v m
|
||||||
WORKDIR /TShock/TShockLauncher
|
WORKDIR /TShock/TShockLauncher
|
||||||
RUN case "${TARGETPLATFORM}" in \
|
RUN \
|
||||||
"linux/amd64") export ARCH="linux-x64" \
|
case "${TARGETPLATFORM}" in \
|
||||||
;; \
|
"linux/amd64") export ARCH="linux-x64" \
|
||||||
"linux/arm64") export ARCH="linux-arm64" \
|
;; \
|
||||||
;; \
|
"linux/arm64") export ARCH="linux-arm64" \
|
||||||
"linux/arm/v7") export ARCH="linux-arm" \
|
;; \
|
||||||
;; \
|
"linux/arm/v7") export ARCH="linux-arm" \
|
||||||
"windows/amd64") export ARCH="win-x64" \
|
;; \
|
||||||
;; \
|
"windows/amd64") export ARCH="win-x64" \
|
||||||
*) echo "Error: Unsupported platform ${TARGETPLATFORM}" && exit 1 \
|
;; \
|
||||||
;; \
|
*) echo "Error: Unsupported platform ${TARGETPLATFORM}" && exit 1 \
|
||||||
|
;; \
|
||||||
esac && \
|
esac && \
|
||||||
dotnet publish -o output/ -r "${ARCH}" -v m -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false
|
dotnet publish -o output/ -r "${ARCH}" -v m -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,45 @@
|
||||||
# Docker Setup
|
# Docker Setup
|
||||||
|
|
||||||
## Build Image:
|
In order to run TShock in a docker container, you would need to have mountpoints for
|
||||||
`docker build -t tshock .`
|
- `/tshock` (TShock config files, logs and crash reports)
|
||||||
## and run:
|
- `/worlds`
|
||||||
|
- `/plugins`
|
||||||
|
- `/server` (optional, if you want to mount TShock's cwd)
|
||||||
|
|
||||||
|
These folders can be mounted using `-v <host_folder>:<container>`
|
||||||
|
|
||||||
|
Open ports can also be passed through using `-p <host_port>:<container_port>`.
|
||||||
|
- `7777` for Terraria
|
||||||
|
- `7878` for TShock's REST API
|
||||||
|
|
||||||
|
For Example:
|
||||||
```bash
|
```bash
|
||||||
|
# Building the image
|
||||||
|
docker build -t tshock:linux-x64 --build-arg TARGETPLATFORM=linux-x64 .
|
||||||
|
|
||||||
|
# Running the image
|
||||||
docker run -p 7777:7777 -p 7878:7878 \
|
docker run -p 7777:7777 -p 7878:7878 \
|
||||||
-v <save path>:/tshock \
|
-v /home/cider/tshock/:/tshock \
|
||||||
-v <world path>:/worlds \
|
-v /home/cider/.local/share/Terraria/Worlds:/worlds \
|
||||||
-v <plugin path>:/plugins \
|
-v /home/cider/tshock/plugins:/plugins \
|
||||||
--rm -it tshock [-world /worlds/<world file>] <other cmdline flags>
|
--rm -it tshock:linux-x64 \
|
||||||
|
-world /worlds/backflip.wld -motd "OMFG DOCKER"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building for Other Platforms
|
||||||
|
|
||||||
|
Using `docker buildx`, you could build [multi-platform images](https://docs.docker.com/build/building/multi-platform/) for TShock.
|
||||||
|
|
||||||
|
For Example:
|
||||||
|
```bash
|
||||||
|
# Building the image using buildx and loading it into docker
|
||||||
|
sudo docker buildx build -t tshock:linux-arm64 --platform linux/arm64 --load .
|
||||||
|
|
||||||
|
# Running the image
|
||||||
|
docker run -p 7777:7777 -p 7878:7878 \
|
||||||
|
-v /home/cider/tshock/:/tshock \
|
||||||
|
-v /home/cider/.local/share/Terraria/Worlds:/worlds \
|
||||||
|
-v /home/cider/tshock/plugins:/plugins \
|
||||||
|
--rm -it tshock:linux-arm64 \
|
||||||
|
-world /worlds/backflip.wld -motd "ARM64 ftw"
|
||||||
```
|
```
|
||||||
Loading…
Add table
Add a link
Reference in a new issue