Skip to content

Commit

Permalink
kaniko platform
Browse files Browse the repository at this point in the history
  • Loading branch information
arttor committed Apr 24, 2024
1 parent 02ee23d commit d40c5c8
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 35 deletions.
85 changes: 56 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,67 @@ jobs:
kaniko:
strategy:
matrix:
arch: [amd64, arm64]
service: [worker, proxy, agent]
# arch: [amd64, arm64]
# service: [worker, proxy, agent]
service: [ proxy]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: docker build and push
uses: aevea/[email protected]
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: harbor.clyso.com
username: "${{ secrets.DOCKER_USER }}"
password: ${{ secrets.DOCKER_PASSWORD }}
image: chorus/${{ matrix.service }}-${{ matrix.arch }}
build_file: Dockerfile
tag: test2
# tag: ${{ github.ref_name }}
strip_tag_prefix: v
tag_with_latest: false
extra_args: "--custom-platform=linux/${{ matrix.arch }} --build-arg GIT_TAG=${{ github.ref_name }} --build-arg GIT_COMMIT=${{ github.sha }} --build-arg SERVICE=${{ matrix.service }} --build-arg GOARCH=${{ matrix.arch }}"
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: chorus/${{ matrix.service }}:test2
build-args:
- GIT_TAG=${{ github.ref_name }}
- GIT_COMMIT=${{ github.sha }}
- SERVICE=${{ matrix.service }}
# - uses: actions/checkout@v3
# - name: docker build and push
# uses: aevea/[email protected]
# with:
# registry: harbor.clyso.com
# username: "${{ secrets.DOCKER_USER }}"
# password: ${{ secrets.DOCKER_PASSWORD }}
# image: chorus/${{ matrix.service }}-${{ matrix.arch }}
# build_file: Dockerfile
# tag: test2
# # tag: ${{ github.ref_name }}
# strip_tag_prefix: v
# tag_with_latest: false
# extra_args: "--custom-platform=linux/${{ matrix.arch }} --build-arg GIT_TAG=${{ github.ref_name }} --build-arg GIT_COMMIT=${{ github.sha }} --build-arg SERVICE=${{ matrix.service }} --build-arg GOARCH=${{ matrix.arch }}"
# upload docker manifest to support multi-arch images
manifest:
needs: kaniko
runs-on: ubuntu-latest
strategy:
matrix:
service: [worker, proxy, agent]
steps:
- name: Push manifest
uses: pixelfederation/[email protected] #check for latest tag
with:
username: "${{ secrets.DOCKER_USER }}"
password: ${{ secrets.DOCKER_PASSWORD }}
platforms: linux/amd64,linux/arm64
template: harbor.clyso.com/chorus/${{ matrix.service }}-ARCH:test2
target: harbor.clyso.com/chorus/${{ matrix.service }}:test2
# manifest:
# needs: kaniko
# runs-on: ubuntu-latest
# strategy:
# matrix:
# service: [worker, proxy, agent]
# steps:
# - name: Push manifest
# uses: pixelfederation/[email protected] #check for latest tag
# with:
# username: "${{ secrets.DOCKER_USER }}"
# password: ${{ secrets.DOCKER_PASSWORD }}
# platforms: linux/amd64,linux/arm64
# template: harbor.clyso.com/chorus/${{ matrix.service }}-ARCH:test2
# target: harbor.clyso.com/chorus/${{ matrix.service }}:test2
# template: harbor.clyso.com/chorus/${{ matrix.service }}-ARCH:${{ github.ref_name }}
# target: harbor.clyso.com/chorus/${{ matrix.service }}:${{ github.ref_name }}
# - name: Tag latest
Expand Down
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM --platform=$BUILDPLATFORM golang:1.21 as builder
FROM golang:1.21 as builder
# FROM --platform=$BUILDPLATFORM golang:1.21 as builder
ARG GIT_COMMIT='not set'
ARG GIT_TAG=development
ENV GIT_COMMIT=$GIT_COMMIT
Expand All @@ -15,17 +16,18 @@ COPY . .

ARG GOOS=linux
# amd64| arm64
ARG GOARCH=amd64
ENV GOARCH=$GOARCH
# ARG GOARCH=amd64
# worker|proxy|agent
ARG SERVICE=worker

RUN CGO_ENABLED=0 GO111MODULE=on GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-X 'main.version=$GIT_TAG' -X 'main.commit=$GIT_COMMIT'" -o chorus ./cmd/${SERVICE}
RUN CGO_ENABLED=0 GO111MODULE=on GOOS=$GOOS GOARCH=${TARGETARCH} go build -ldflags="-X 'main.version=$GIT_TAG' -X 'main.commit=$GIT_COMMIT'" -o chorus ./cmd/${SERVICE}

# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM --platform=$TARGETPLATFORM scratch
FROM gcr.io/distroless/static:nonroot
# FROM --platform=$TARGETPLATFORM gcr.io/distroless/static:nonroot
USER nonroot:nonroot
WORKDIR /bin

COPY --from=builder /build/chorus chorus
COPY --chown=nonroot:nonroot --from=builder /build/chorus chorus

CMD ["chorus"]

0 comments on commit d40c5c8

Please sign in to comment.