Skip to content

Commit

Permalink
Clear default Dockerfile assignments for *PLATFORM
Browse files Browse the repository at this point in the history
These kept Docker buildx from automatically building for multiple
platforms.
  • Loading branch information
timschumi committed Oct 1, 2023
1 parent 60599ef commit a413c51
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
ARG TARGETPLATFORM=linux/amd64
ARG BUILDPLATFORM=${TARGETPLATFORM}
# 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

ARG TARGETPLATFORM

# 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" \
Expand Down
8 changes: 4 additions & 4 deletions docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ Open ports can also be passed through using `-p <host_port>:<container_port>`.

For Example:
```bash
# Building the image
docker build -t tshock:linux-amd64 --build-arg TARGETPLATFORM=linux/amd64 .
# Building the image using buildx and loading it into docker
docker buildx build -t tshock:latest --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-amd64 \
--rm -it tshock:latest \
-world /worlds/backflip.wld -motd "OMFG DOCKER"
```

Expand All @@ -33,7 +33,7 @@ Using `docker buildx`, you could build [multi-platform images](https://docs.dock
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 .
docker buildx build -t tshock:linux-arm64 --platform linux/arm64 --load .

# Running the image
docker run -p 7777:7777 -p 7878:7878 \
Expand Down

0 comments on commit a413c51

Please sign in to comment.