arm64 docker image builds
This commit is contained in:
66
.github/workflows/docker-publish.yml
vendored
66
.github/workflows/docker-publish.yml
vendored
@@ -10,7 +10,18 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- arch: amd64
|
||||||
|
docker-platform: linux/amd64
|
||||||
|
tag-suffix: ""
|
||||||
|
- arch: arm64
|
||||||
|
docker-platform: linux/arm64
|
||||||
|
tag-suffix: "-arm64"
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
architecture: ${{ matrix.arch }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -27,11 +38,22 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ env.OCI_TOKEN }}
|
password: ${{ env.OCI_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Extract Docker metadata
|
- name: Extract Docker metadata
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ vars.OCI_REGISTRY || 'ghcr.io' }}/${{ github.repository }}
|
images: ${{ vars.OCI_REGISTRY || 'ghcr.io' }}/${{ github.repository }}
|
||||||
|
tags: |
|
||||||
|
type=schedule
|
||||||
|
type=ref,event=branch
|
||||||
|
type=semver,pattern={{version}}${{ matrix.tag_suffix }}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}${{ matrix.tag_suffix }}
|
||||||
|
type=semver,pattern={{major}}${{ matrix.tag_suffix }}
|
||||||
|
type=raw,value=latest${{ matrix.tag_suffix }},enable={{is_default_branch}}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
@@ -40,3 +62,47 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
platforms: ${{ matrix.docker_platform }}
|
||||||
|
build-args: TARGETARCH=${{ matrix.arch }}
|
||||||
|
|
||||||
|
combine-manifests:
|
||||||
|
needs: build-and-push
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Log in to GHCR
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ vars.OCI_REGISTRY || 'ghcr.io' }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ env.OCI_TOKEN }}
|
||||||
|
|
||||||
|
- name: Create combined manifest
|
||||||
|
run: |
|
||||||
|
# Get the base image name
|
||||||
|
IMAGE_NAME=${{ vars.OCI_REGISTRY || 'ghcr.io' }}/${{ github.repository }}
|
||||||
|
|
||||||
|
# Determine tags based on ref_type (branch/tag)
|
||||||
|
if [[ "${{ github.ref_type }}" == "tag" ]]; then
|
||||||
|
TAG_VERSION="${{ github.ref_name }}" # e.g., v1.0.0
|
||||||
|
TAG_LATEST="latest"
|
||||||
|
elif [[ "${{ github.ref_name }}" == "refs/heads/main" ]]; then
|
||||||
|
TAG_VERSION="" # No version tag for main head
|
||||||
|
TAG_LATEST="latest"
|
||||||
|
else
|
||||||
|
echo "Skipping manifest for non-tag/non-main branch"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$TAG_LATEST" ]; then
|
||||||
|
docker buildx imagetools create -t ${IMAGE_NAME}:${TAG_LATEST} \
|
||||||
|
${IMAGE_NAME}:${TAG_LATEST}-amd64 \
|
||||||
|
${IMAGE_NAME}:${TAG_LATEST}-arm64
|
||||||
|
echo "Created multi-arch manifest for ${IMAGE_NAME}:${TAG_LATEST}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$TAG_VERSION" ]; then
|
||||||
|
docker buildx imagetools create -t ${IMAGE_NAME}:${TAG_VERSION} \
|
||||||
|
${IMAGE_NAME}:${TAG_VERSION}-amd64 \
|
||||||
|
${IMAGE_NAME}:${TAG_VERSION}-arm64
|
||||||
|
echo "Created multi-arch manifest for ${IMAGE_NAME}:${TAG_VERSION}"
|
||||||
|
fi
|
||||||
|
|||||||
22
Dockerfile
22
Dockerfile
@@ -3,21 +3,33 @@ FROM golang:1.25 AS builder
|
|||||||
# build dependencies
|
# build dependencies
|
||||||
RUN apt update && apt install -y upx
|
RUN apt update && apt install -y upx
|
||||||
|
|
||||||
RUN curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/download/v4.1.13/tailwindcss-linux-x64
|
ARG TARGETARCH
|
||||||
RUN chmod +x tailwindcss-linux-x64
|
RUN set -eux; \
|
||||||
RUN mv tailwindcss-linux-x64 /usr/local/bin/tailwindcss
|
echo "Building for architecture: ${TARGETARCH}"; \
|
||||||
|
case "${TARGETARCH}" in \
|
||||||
|
"amd64") \
|
||||||
|
arch_suffix='x64' ;; \
|
||||||
|
"arm64") \
|
||||||
|
arch_suffix='arm64' ;; \
|
||||||
|
*) \
|
||||||
|
echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
|
||||||
|
esac; \
|
||||||
|
curl -sLO "https://github.com/tailwindlabs/tailwindcss/releases/download/v4.1.13/tailwindcss-linux-${arch_suffix}"; \
|
||||||
|
mv "tailwindcss-linux-${arch_suffix}" /usr/local/bin/tailwindcss; \
|
||||||
|
chmod +x /usr/local/bin/tailwindcss;
|
||||||
|
|
||||||
|
|
||||||
RUN go install github.com/juls0730/zqdgr@latest
|
RUN go install github.com/juls0730/zqdgr@latest
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
|
ARG TARGETARCH
|
||||||
|
ENV CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH}
|
||||||
|
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|
||||||
RUN zqdgr build
|
RUN zqdgr build
|
||||||
RUN upx passport
|
RUN upx passport
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user