Skip to content

Commit

Permalink
Merge pull request #247 from kubeservice-stack/chores-build
Browse files Browse the repository at this point in the history
chores: build muti-arch image with github action
  • Loading branch information
peter-wangxu authored Dec 13, 2023
2 parents 6b83f8f + 7f886b7 commit 7951134
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: build and release package

on:
push:
tags: [ 'v*' ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: 'bash -Eeuo pipefail -x {0}'

env:
REGISTRY: ghcr.io

jobs:
generate-jobs:
name: open-local
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
-
name: open-local
image: alibaba/open-local
file: ./Dockerfile.muti
platforms: linux/amd64,linux/arm64

steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up Go
uses: actions/setup-go@v2.1.4
with:
go-version: 1.18
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ matrix.image}}
tags: |
type=ref,event=tag
type=semver,pattern={{raw}}
-
name: Build and push
uses: docker/build-push-action@v5
with:
file: ${{ matrix.file }}
platforms: ${{ matrix.platforms }}
push: true
tags: |
${{ env.REGISTRY }}/${{ matrix.image }}:latest
${{ steps.meta.outputs.tags }}
- name: Test ${{ matrix.name }}
run: |
docker pull ${{ env.REGISTRY }}/${{ matrix.image }}:latest
docker image inspect ${{ env.REGISTRY }}/${{ matrix.image}}:latest
42 changes: 42 additions & 0 deletions Dockerfile.muti
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM golang:1.18 AS builder

WORKDIR /go/src/github.com/alibaba/open-local
COPY . .
RUN make build && chmod +x bin/open-local

FROM openlocal/open-local-base:latest
LABEL maintainers="Alibaba Cloud Authors"
LABEL description="open-local is a local disk management system"
COPY --from=builder /go/src/github.com/alibaba/open-local/bin/open-local /bin/open-local
RUN set -eux; \
arch="$(apk --print-arch)"; \
case "$arch" in \
'x86_64') \
wget https://github.com/restic/restic/releases/download/v0.12.1/restic_0.12.1_linux_amd64.bz2 \
bunzip2 restic_0.12.1_linux_amd64.bz2 && mv restic_0.12.0_linux_amd64 /usr/local/bin/restic && chmod +x /usr/local/bin/restic \
rm -rf restic_0.12.1_linux_amd64.bz2 \
;; \
'aarch64') \
wget https://github.com/restic/restic/releases/download/v0.12.1/restic_0.12.1_linux_arm64.bz2 \
bunzip2 restic_0.12.1_linux_arm64.bz2 && mv restic_0.12.0_linux_arm64 /usr/local/bin/restic && chmod +x /usr/local/bin/restic \
rm -rf restic_0.12.1_linux_arm64.bz2 \
;; \
'x86') \
wget https://github.com/restic/restic/releases/download/v0.12.1/restic_0.12.1_linux_386.bz2 \
bunzip2 restic_0.12.1_linux_386.bz2 && mv restic_0.12.0_linux_386 /usr/local/bin/restic && chmod +x /usr/local/bin/restic \
rm -rf restic_0.12.1_linux_386.bz2 \
;; \
'ppc64le') \
wget https://github.com/restic/restic/releases/download/v0.12.1/restic_0.12.1_linux_ppc64le.bz2 \
bunzip2 restic_0.12.1_linux_ppc64le.bz2 && mv restic_0.12.0_linux_ppc64le /usr/local/bin/restic && chmod +x /usr/local/bin/restic \
rm -rf restic_0.12.1_linux_ppc64le.bz2 \
;; \
's390x') \
wget https://github.com/restic/restic/releases/download/v0.12.1/restic_0.12.1_linux_s390x.bz2 \
bunzip2 restic_0.12.1_linux_s390x.bz2 && mv restic_0.12.0_linux_s390x /usr/local/bin/restic && chmod +x /usr/local/bin/restic \
rm -rf restic_0.12.1_linux_s390x.bz2 \
;; \
*) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)"; exit 1 ;; \
esac; \

ENTRYPOINT ["open-local"]

0 comments on commit 7951134

Please sign in to comment.