Skip to content

Commit

Permalink
Merge pull request #133 from Somefive/add-release-for-ghcr-acr-image
Browse files Browse the repository at this point in the history
Feat: add release action for ghcr & acr image
  • Loading branch information
Somefive authored Apr 3, 2023
2 parents 676e69c + 97c01ab commit 9563c0f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 9 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: BuildImage

on:
push:
branches:
- master
tags:
- 'v*'
workflow_dispatch: {}

jobs:
build-push-acr-and-ghcr-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/oam-dev/cluster-gateway
acr.kubevela.net/oamdev/cluster-gateway
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest,enable={{is_default_branch}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to ACR Registry
uses: docker/login-action@v2
with:
registry: acr.kubevela.net
username: ${{ vars.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}

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

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
file: ./cmd/apiserver/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 1 addition & 0 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ jobs:
tag: ${{ needs.env.outputs.RELEASE_VERSION }}
artifacts: "go/src/oamdev/cluster-gateway/release/*.tgz"
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
- name: submit charts to OCM chart repo
uses: actions/github-script@v6
with:
Expand Down
13 changes: 4 additions & 9 deletions cmd/apiserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
ARG OS=linux
ARG ARCH=amd64
# Build the manager binary
FROM golang:1.19 as builder
FROM golang:1.19-alpine as builder
ARG OS
ARG ARCH

Expand All @@ -24,24 +22,21 @@ ARG API_GROUP_NAME=cluster.core.oam.dev
RUN CGO_ENABLED=0 \
GOOS=${OS} \
GOARCH=${ARCH} \
GO111MODULE=on \
go build \
-ldflags="-X 'github.com/oam-dev/cluster-gateway/pkg/config.MetaApiGroupName=${API_GROUP_NAME}'" \
-a -o apiserver \
-o apiserver \
cmd/apiserver/main.go

RUN CGO_ENABLED=0 \
GOOS=${OS} \
GOARCH=${ARCH} \
GO111MODULE=on \
go build \
-a -o patch \
-o patch \
hack/patch/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
ARG ARCH
FROM multiarch/alpine:${ARCH}-v3.13
FROM alpine:3.17

WORKDIR /
COPY --from=builder /workspace/apiserver /
Expand Down

0 comments on commit 9563c0f

Please sign in to comment.