-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate multi-platform Docker images (#1316)
Enable cross-compilation in Dockerfiles. Add build script. Update instructions around emulation support. Add GH actions to build and push dsym and pluginbuilder images on releases. --------- Co-authored-by: Fernando Takagi <[email protected]>
- Loading branch information
Showing
17 changed files
with
262 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: dockerhub-nakama-dsym | ||
|
||
on: | ||
release: | ||
types: | ||
- created | ||
|
||
jobs: | ||
nakama_dsym_build_publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Set env vars | ||
run: | | ||
echo "ARG_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
echo "ARG_VERSION=$(echo -n ${{ github.event.release.name }} | cut -c2-)" >> $GITHUB_ENV | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# Extract metadata (tags, labels) for Docker | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ github.repository }}-dsym | ||
tags: | | ||
type=semver,pattern={{version}} | ||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
file: "build/Dockerfile.dsym" | ||
build-args: | | ||
COMMIT=${{ env.ARG_COMMIT }} | ||
VERSION=${{ env.ARG_VERSION }} | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: dockerhub-nakama | ||
|
||
on: | ||
release: | ||
types: | ||
- created | ||
|
||
jobs: | ||
nakama_build_publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Set env vars | ||
run: | | ||
echo "ARG_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
echo "ARG_VERSION=$(echo -n ${{ github.event.release.name }} | cut -c2-)" >> $GITHUB_ENV | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# Extract metadata (tags, labels) for Docker | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ github.repository }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
file: "build/Dockerfile" | ||
build-args: | | ||
COMMIT=${{ env.ARG_COMMIT }} | ||
VERSION=${{ env.ARG_VERSION }} | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: dockerhub-pluginbuilder | ||
|
||
on: | ||
release: | ||
types: | ||
- created | ||
|
||
jobs: | ||
pluginbuilder_build_publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Set env vars | ||
run: | | ||
echo "ARG_VERSION=$(echo -n ${{ github.event.release.name }} | cut -c2-)" >> $GITHUB_ENV | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# Extract metadata (tags, labels) for Docker | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ github.repository }}-pluginbuilder | ||
tags: | | ||
type=semver,pattern={{version}} | ||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
file: "build/pluginbuilder/Dockerfile" | ||
build-args: | | ||
VERSION=${{ env.ARG_VERSION }} | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,38 +12,41 @@ | |
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
|
||
# docker build "$PWD" --build-arg commit="$(git rev-parse --short HEAD)" --build-arg version=v2.1.1 -t heroiclabs/nakama:2.1.1 | ||
# docker build "$PWD" --build-arg commit="$(git rev-parse --short HEAD)" --build-arg version="$(git rev-parse --short HEAD)" -t heroiclabs/nakama-prerelease:"$(git rev-parse --short HEAD)" | ||
# docker build . --build-arg commit="$(git rev-parse --short HEAD)" --build-arg version=v2.1.1 -t heroiclabs/nakama:2.1.1 | ||
# docker build . --build-arg commit="$(git rev-parse --short HEAD)" --build-arg version="$(git rev-parse --short HEAD)" -t heroiclabs/nakama-prerelease:"$(git rev-parse --short HEAD)" | ||
|
||
FROM golang:1.23.3-bookworm as builder | ||
FROM golang:1.23.5-bookworm AS builder | ||
|
||
ARG commit | ||
ARG version | ||
ARG COMMIT | ||
ARG VERSION | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
ENV GOOS linux | ||
ENV GOARCH amd64 | ||
ENV CGO_ENABLED 1 | ||
ENV GOOS=$TARGETOS | ||
ENV GOARCH=$TARGETARCH | ||
ENV CGO_ENABLED=1 | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update && \ | ||
apt-get -y upgrade && \ | ||
apt-get install -y --no-install-recommends ca-certificates gcc libc6-dev git && \ | ||
git config --global advice.detachedHead false && \ | ||
git clone --quiet --no-checkout https://github.com/heroiclabs/nakama /go/build/nakama | ||
apt-get install -y --no-install-recommends ca-certificates gcc libc6-dev | ||
|
||
WORKDIR /go/build/nakama | ||
RUN git checkout --quiet "$commit" && \ | ||
go build -o /go/build-out/nakama -trimpath -mod=vendor -gcflags "-trimpath $PWD" -asmflags "-trimpath $PWD" -ldflags "-s -w -X main.version=$version -X main.commitID=$commit" | ||
COPY . . | ||
RUN go build -o /go/build-out/nakama -trimpath -mod=vendor -gcflags "-trimpath $PWD" -asmflags "-trimpath $PWD" -ldflags "-s -w -X main.version=$VERSION -X main.commitID=$COMMIT" | ||
|
||
FROM debian:bookworm-slim | ||
|
||
MAINTAINER Heroic Labs <[email protected]> | ||
ARG VERSION | ||
|
||
ARG version | ||
|
||
LABEL version=$version | ||
LABEL maintainer="Heroic Labs" | ||
LABEL contact="[email protected]" | ||
LABEL version=$VERSION | ||
LABEL variant=nakama | ||
LABEL description="Distributed server for social and realtime games and apps." | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN mkdir -p /nakama/data/modules && \ | ||
apt-get update && \ | ||
apt-get -y upgrade && \ | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,37 +12,37 @@ | |
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
|
||
# docker build "$PWD" --build-arg commit="$(git rev-parse --short HEAD)" --build-arg version=v3.19.0 -t heroiclabs/nakama:3.19.0 | ||
# docker build "$PWD" --build-arg commit="$(git rev-parse --short HEAD)" --build-arg version="v3.19.0-$(git rev-parse --short HEAD)" -t heroiclabs/nakama-prerelease:"3.19.0-$(git rev-parse --short HEAD)" | ||
FROM golang:1.23.5-bookworm AS builder | ||
|
||
FROM golang:1.23.3-bookworm as builder | ||
ARG COMMIT | ||
ARG VERSION | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
ARG commit | ||
ARG version | ||
|
||
ENV GOOS linux | ||
ENV GOARCH amd64 | ||
ENV CGO_ENABLED 1 | ||
ENV GOOS=$TARGETOS | ||
ENV GOARCH=$TARGETARCH | ||
ENV CGO_ENABLED=1 | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update && \ | ||
apt-get -y upgrade && \ | ||
apt-get install -y --no-install-recommends ca-certificates gcc libc6-dev git && \ | ||
git config --global advice.detachedHead false && \ | ||
git clone --quiet --no-checkout https://github.com/heroiclabs/nakama /go/build/nakama | ||
apt-get install -y --no-install-recommends ca-certificates gcc libc6-dev | ||
|
||
WORKDIR /go/build/nakama | ||
RUN git checkout --quiet "$commit" && \ | ||
go build -o /go/build-out/nakama -trimpath -mod=vendor -gcflags "all=-N -l" -ldflags "-X main.version=$version -X main.commitID=$commit" | ||
COPY . . | ||
RUN go build -o /go/build-out/nakama -trimpath -mod=vendor -gcflags "all=-N -l" -ldflags "-X main.version=$VERSION -X main.commitID=$COMMIT" | ||
|
||
FROM debian:bookworm-slim | ||
|
||
MAINTAINER Heroic Labs <[email protected]> | ||
|
||
ARG version | ||
ARG VERSION | ||
|
||
LABEL version=$version | ||
LABEL maintainer="Heroic Labs" | ||
LABEL contact="[email protected]" | ||
LABEL version=$VERSION | ||
LABEL variant=nakama | ||
LABEL description="Distributed server for social and realtime games and apps." | ||
LABEL description="Distributed server for social and realtime games and apps with debug symbols." | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN mkdir -p /nakama/data/modules && \ | ||
apt-get update && \ | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.