Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Unify Dockerfiles #364

Merged
merged 6 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 3 additions & 40 deletions .github/workflows/developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: # yamllint disable-line rule:truthy
branches: [main]

jobs:
push-amd64:
push:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -24,62 +24,25 @@ 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
with:
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 }}
7 changes: 7 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
50 changes: 6 additions & 44 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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 }}
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 40 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
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="[email protected]" \
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"

# 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 \
Expand All @@ -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
Expand Down
113 changes: 0 additions & 113 deletions Dockerfile.arm64

This file was deleted.

Loading