diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 429c34f1..bc134f6e 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -5,7 +5,7 @@ on: # yamllint disable-line rule:truthy branches: [main] jobs: - push-amd64: + push: runs-on: ubuntu-latest steps: - name: Checkout @@ -24,48 +24,12 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker - Metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ${{ github.repository }} - ghcr.io/${{ github.repository }} - tags: type=raw,value=dev - flavor: latest=false - - - name: Docker - Build / Push - uses: docker/build-push-action@v5 - with: - platforms: linux/amd64 - push: true - tags: ${{ steps.meta.outputs.tags }} - - push-arm64: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Docker - Login - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Docker - GHCR Login - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker - Metadata id: meta uses: docker/metadata-action@v5 @@ -73,13 +37,12 @@ jobs: images: | ${{ github.repository }} ghcr.io/${{ github.repository }} - tags: type=raw,value=dev-arm64 + tags: type=raw,value=dev flavor: latest=false - name: Docker - Build / Push uses: docker/build-push-action@v5 with: - file: Dockerfile.arm64 - platforms: linux/arm64 + platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index b84f2f47..d243e448 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -54,7 +54,14 @@ jobs: name: Docker - Build runs-on: ubuntu-latest steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Docker - Build uses: docker/build-push-action@v5 with: push: false + platforms: linux/amd64,linux/arm64 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 902dfe5e..778755a5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: # yamllint disable-line rule:truthy jobs: # Builds the Dockerfile and pushes it to dockerhub and GHCR - release-amd64: + release: name: Release - Docker image runs-on: ubuntu-latest steps: @@ -26,48 +26,12 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker - Metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ${{ github.repository }} - ghcr.io/${{ github.repository }} - # generate Docker tags based on the following events/attributes - tags: | - type=semver,pattern=v{{version}} - type=semver,pattern=v{{major}}.{{minor}} - type=semver,pattern=v{{major}} - flavor: latest=true - - - name: Docker - Build / Push - id: docker_build - uses: docker/build-push-action@v5 - with: - platforms: linux/amd64 - push: true - tags: ${{ steps.meta.outputs.tags }} - - # Builds the Dockerfile.arm64 and pushes it to dockerhub and GHCR - release-arm64: - name: Release - Docker image - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Docker - Login - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Docker - Metadata id: meta uses: docker/metadata-action@v5 @@ -77,17 +41,15 @@ jobs: ghcr.io/${{ github.repository }} # generate Docker tags based on the following events/attributes tags: | - type=semver,pattern=v{{version}}-arm64 - type=semver,pattern=v{{major}}.{{minor}}-arm64 - type=semver,pattern=v{{major}}-arm64 - type=raw,value=latest-arm64 - flavor: latest=false + type=semver,pattern=v{{version}} + type=semver,pattern=v{{major}}.{{minor}} + type=semver,pattern=v{{major}} + flavor: latest=true - name: Docker - Build / Push id: docker_build uses: docker/build-push-action@v5 with: - file: Dockerfile.arm64 - platforms: linux/arm64 + platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 3016f52a..7338c382 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -115,7 +115,7 @@ jobs: - name: Build and export to Docker uses: docker/build-push-action@v5 with: - file: ./Dockerfile.arm64 + file: ./Dockerfile load: true tags: ${{ github.run_id }} platforms: linux/arm64 diff --git a/Dockerfile b/Dockerfile index 7646e4ab..6d418362 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,28 @@ -FROM cm2network/steamcmd:root +FROM golang:1.22.0-alpine as rcon-cli_builder + +ARG RCON_VERSION="0.10.3" + +WORKDIR /build + +ENV CGO_ENABLED=0 +RUN wget -q https://github.com/gorcon/rcon-cli/archive/refs/tags/v${RCON_VERSION}.tar.gz -O rcon.tar.gz \ + && tar -xzvf rcon.tar.gz \ + && rm rcon.tar.gz \ + && mv rcon-cli-${RCON_VERSION}/* ./ \ + && rm -rf rcon-cli-${RCON_VERSION} \ + && go build -v ./cmd/gorcon + +FROM cm2network/steamcmd:root as base-amd64 +# Ignoring --platform=arm64 as this is required for the multi-arch build to continue to work on amd64 hosts +# hadolint ignore=DL3029 +FROM --platform=arm64 sonroyaalmerol/steamcmd-arm64:root as base-arm64 + +ARG TARGETARCH +# Ignoring the lack of a tag here because the tag is defined in the above FROM lines +# and hadolint isn't aware of those. +# hadolint ignore=DL3006 +FROM base-${TARGETARCH} + LABEL maintainer="thijs@loef.dev" \ name="thijsvanloef/palworld-server-docker" \ github="https://github.com/thijsvanloef/palworld-server-docker" \ @@ -6,6 +30,14 @@ LABEL maintainer="thijs@loef.dev" \ org.opencontainers.image.authors="Thijs van Loef" \ org.opencontainers.image.source="https://github.com/thijsvanloef/palworld-server-docker" +# set envs +# SUPERCRONIC: Latest releases available at https://github.com/aptible/supercronic/releases +# RCON: Latest releases available at https://github.com/gorcon/rcon-cli/releases +# NOTICE: edit RCON_MD5SUM SUPERCRONIC_SHA1SUM when using binaries of another version or arch. +ARG SUPERCRONIC_SHA1SUM_ARM64="512f6736450c56555e01b363144c3c9d23abed4c" +ARG SUPERCRONIC_SHA1SUM_AMD64="cd48d45c4b10f3f0bfdd3a57d054cd05ac96812b" +ARG SUPERCRONIC_VERSION="0.2.29" + # update and install dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ procps=2:3.3.17-5 \ @@ -16,26 +48,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -# set envs -# SUPERCRONIC: Latest releases available at https://github.com/aptible/supercronic/releases -# RCON: Latest releases available at https://github.com/gorcon/rcon-cli/releases -# NOTICE: edit RCON_MD5SUM SUPERCRONIC_SHA1SUM when using binaries of another version or arch. -ENV RCON_MD5SUM="8601c70dcab2f90cd842c127f700e398" \ - SUPERCRONIC_SHA1SUM="cd48d45c4b10f3f0bfdd3a57d054cd05ac96812b" \ - RCON_VERSION="0.10.3" \ - SUPERCRONIC_VERSION="0.2.29" - # install rcon and supercronic SHELL ["/bin/bash", "-o", "pipefail", "-c"] -RUN wget --progress=dot:giga https://github.com/gorcon/rcon-cli/releases/download/v${RCON_VERSION}/rcon-${RCON_VERSION}-amd64_linux.tar.gz -O rcon.tar.gz \ - && echo "${RCON_MD5SUM}" rcon.tar.gz | md5sum -c - \ - && tar -xzvf rcon.tar.gz \ - && rm rcon.tar.gz \ - && mv rcon-${RCON_VERSION}-amd64_linux/rcon /usr/bin/rcon-cli \ - && rmdir /tmp/dumps +COPY --from=rcon-cli_builder /build/gorcon /usr/bin/rcon-cli -RUN wget --progress=dot:giga https://github.com/aptible/supercronic/releases/download/v${SUPERCRONIC_VERSION}/supercronic-linux-amd64 -O supercronic \ +ARG TARGETARCH +RUN case ${TARGETARCH} in \ + "amd64") SUPERCRONIC_SHA1SUM=${SUPERCRONIC_SHA1SUM_AMD64} ;; \ + "arm64") SUPERCRONIC_SHA1SUM=${SUPERCRONIC_SHA1SUM_ARM64} ;; \ + esac \ + && wget --progress=dot:giga https://github.com/aptible/supercronic/releases/download/v${SUPERCRONIC_VERSION}/supercronic-linux-${TARGETARCH} -O supercronic \ && echo "${SUPERCRONIC_SHA1SUM}" supercronic | sha1sum -c - \ && chmod +x supercronic \ && mv supercronic /usr/local/bin/supercronic diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 deleted file mode 100644 index df2d8e2e..00000000 --- a/Dockerfile.arm64 +++ /dev/null @@ -1,113 +0,0 @@ -# set envs -# SUPERCRONIC: Latest releases available at https://github.com/aptible/supercronic/releases -# RCON: Latest releases available at https://github.com/gorcon/rcon-cli/releases -# NOTICE: edit RCON_MD5SUM SUPERCRONIC_SHA1SUM when using binaries of another version or arch. -ARG SUPERCRONIC_SHA1SUM="512f6736450c56555e01b363144c3c9d23abed4c" -ARG RCON_VERSION="0.10.3" -ARG SUPERCRONIC_VERSION="0.2.29" - -# build rcon-cli for arm64-linux -FROM arm64v8/golang:1.22.0-bullseye as rcon-cli_builder - -ARG RCON_VERSION - -WORKDIR /build - -RUN apt-get update && \ - apt-get install -y gcc libc-dev wget && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -RUN wget --progress=dot:giga https://github.com/gorcon/rcon-cli/archive/refs/tags/v${RCON_VERSION}.tar.gz -O rcon.tar.gz \ - && tar -xzvf rcon.tar.gz \ - && rm rcon.tar.gz \ - && mv rcon-cli-${RCON_VERSION}/* ./ \ - && rm -rf rcon-cli-${RCON_VERSION} \ - && go get -v -t -d ./... && env GOARCH=arm64 GOOS=linux go build -v ./cmd/gorcon - -# main image -FROM sonroyaalmerol/steamcmd-arm64:latest - -ARG SUPERCRONIC_SHA1SUM -ARG SUPERCRONIC_VERSION - -USER root - -LABEL maintainer="thijs@loef.dev" \ - name="thijsvanloef/palworld-server-docker" \ - github="https://github.com/thijsvanloef/palworld-server-docker" \ - dockerhub="https://hub.docker.com/r/thijsvanloef/palworld-server-docker" \ - org.opencontainers.image.authors="Thijs van Loef" \ - org.opencontainers.image.source="https://github.com/thijsvanloef/palworld-server-docker" - -# update and install dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - procps=2:3.3.17-5 \ - wget=1.21-1+deb11u1 \ - gettext-base=0.21-4 \ - xdg-user-dirs=0.17-2 \ - jo=1.3-2 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# install rcon and supercronic -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -COPY --from=rcon-cli_builder /build/gorcon /usr/bin/rcon-cli - -RUN wget --progress=dot:giga https://github.com/aptible/supercronic/releases/download/v${SUPERCRONIC_VERSION}/supercronic-linux-arm64 -O supercronic \ - && echo "${SUPERCRONIC_SHA1SUM}" supercronic | sha1sum -c - \ - && chmod +x supercronic \ - && mv supercronic /usr/local/bin/supercronic - -ENV PORT= \ - PUID=1000 \ - PGID=1000 \ - PLAYERS= \ - MULTITHREADING=false \ - COMMUNITY=false \ - PUBLIC_IP= \ - PUBLIC_PORT= \ - SERVER_PASSWORD= \ - SERVER_NAME= \ - ADMIN_PASSWORD= \ - UPDATE_ON_BOOT=true \ - RCON_ENABLED=true \ - RCON_PORT=25575 \ - QUERY_PORT=27015 \ - TZ=UTC \ - SERVER_DESCRIPTION= \ - BACKUP_ENABLED=true \ - DELETE_OLD_BACKUPS=false \ - OLD_BACKUP_DAYS=30 \ - BACKUP_CRON_EXPRESSION="0 0 * * *" \ - AUTO_UPDATE_ENABLED=false \ - AUTO_UPDATE_CRON_EXPRESSION="0 * * * *" \ - AUTO_UPDATE_WARN_MINUTES=30 \ - AUTO_REBOOT_ENABLED=false \ - AUTO_REBOOT_WARN_MINUTES=5 \ - AUTO_REBOOT_EVEN_IF_PLAYERS_ONLINE=false \ - AUTO_REBOOT_CRON_EXPRESSION="0 0 * * *" \ - DISCORD_WEBHOOK_URL= \ - DISCORD_CONNECT_TIMEOUT=30 \ - DISCORD_MAX_TIMEOUT=30 \ - DISCORD_PRE_UPDATE_BOOT_MESSAGE="Server is updating..." \ - DISCORD_POST_UPDATE_BOOT_MESSAGE="Server update complete!" \ - DISCORD_PRE_START_MESSAGE="Server has been started!" \ - DISCORD_PRE_SHUTDOWN_MESSAGE="Server is shutting down..." \ - DISCORD_POST_SHUTDOWN_MESSAGE="Server has been stopped!" - -COPY ./scripts /home/steam/server/ - -RUN chmod +x /home/steam/server/*.sh && \ - mv /home/steam/server/backup.sh /usr/local/bin/backup && \ - mv /home/steam/server/update.sh /usr/local/bin/update && \ - mv /home/steam/server/restore.sh /usr/local/bin/restore - -WORKDIR /home/steam/server - -HEALTHCHECK --start-period=5m \ - CMD pgrep "PalServer-Linux" > /dev/null || exit 1 - -EXPOSE ${PORT} ${RCON_PORT} -ENTRYPOINT ["/home/steam/server/init.sh"] diff --git a/README.md b/README.md index 4e2eadc2..37b99cd4 100644 --- a/README.md +++ b/README.md @@ -54,10 +54,6 @@ Massive shoutout to the following sponsors! Keep in mind that you'll need to change the [environment variables](#environment-variables). -> [!IMPORTANT] -> If you use an ARM64 based CPU (Raspberry pi, M1,M2,M3 Mac, Oracle Cloud Free tier, etc.) -> Please make sure you use the `:latest-arm64` image tag. - ### Docker Compose This repository includes an example [docker-compose.yml](/docker-compose.yml) file you can use to set up your server. @@ -65,7 +61,7 @@ This repository includes an example [docker-compose.yml](/docker-compose.yml) fi ```yml services: palworld: - image: thijsvanloef/palworld-server-docker:latest # Use the latest-arm64 tag for arm64 hosts + image: thijsvanloef/palworld-server-docker:latest restart: unless-stopped container_name: palworld-server stop_grace_period: 30s # Set to however long you are willing to wait for the container to gracefully stop @@ -97,7 +93,7 @@ values. Modify your [docker-compose.yml](docker-compose.yml) to this: ```yml services: palworld: - image: thijsvanloef/palworld-server-docker:latest # Use the latest-arm64 tag for arm64 hosts + image: thijsvanloef/palworld-server-docker:latest restart: unless-stopped container_name: palworld-server stop_grace_period: 30s # Set to however long you are willing to wait for the container to gracefully stop @@ -135,7 +131,7 @@ docker run -d \ -e SERVER_DESCRIPTION="palworld-server-docker by Thijs van Loef" \ --restart unless-stopped \ --stop-timeout 30 \ - thijsvanloef/palworld-server-docker:latest # Use the latest-arm64 tag for arm64 hosts + thijsvanloef/palworld-server-docker:latest ``` As an alternative, you can copy the [.env.example](.env.example) file to a new file called **.env** file. @@ -151,7 +147,7 @@ docker run -d \ --env-file .env \ --restart unless-stopped \ --stop-timeout 30 \ - thijsvanloef/palworld-server-docker:latest # Use the latest-arm64 tag for arm64 hosts + thijsvanloef/palworld-server-docker:latest ``` ### Kubernetes