Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chores: build muti-arch image with github action #247

Merged
merged 4 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
dongjiang1989 marked this conversation as resolved.
Show resolved Hide resolved
-
name: Set up Go
uses: actions/[email protected]
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks restic tools is not included ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... I miss it. Fixed, Please re-check.

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"]
Loading