Skip to content

Commit

Permalink
chore(docker): update multi-arch build image (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
incubator4 authored Feb 1, 2024
1 parent e5f09bc commit 47fab7d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 18 deletions.
59 changes: 44 additions & 15 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,47 @@ on:

jobs:
build:
uses: NaturalSelectionLabs/Daedalus/.github/workflows/docker-tpl.yaml@main
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
with:
images: rss3/node
context: .
dockerfile: ./Dockerfile
platforms: ${{ matrix.platform }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/node
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-,enable=${{ !startsWith(github.ref, 'refs/tags') }},event=branch
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm/v7,linux/arm64
cache-from: type=gha,scope=docker-release
cache-to: type=gha,mode=max,scope=docker-release
15 changes: 12 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
FROM golang:1.21.4-alpine AS builder
FROM golang:1.21.4-alpine AS base

WORKDIR /root/node
RUN apk add --no-cache git make gcc libc-dev

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download -x

COPY . .
RUN apk add --no-cache git make gcc libc-dev

RUN CGO_ENABLED=1 make build
FROM base AS builder

ENV CGO_ENABLED=1
RUN --mount=type=cache,target=/go/pkg/mod/ \
make build

FROM alpine:3.18.4 AS runner

Expand Down

0 comments on commit 47fab7d

Please sign in to comment.