Skip to content

Commit

Permalink
Actions: Mutli Arch Build For Develop/Main tags
Browse files Browse the repository at this point in the history
  • Loading branch information
JFryy committed Jun 30, 2024
1 parent 27994dd commit 2d48fcb
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 16 deletions.
37 changes: 28 additions & 9 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,42 @@ on:
push:
branches:
- 'main'
#TODO: handling
#- 'develop'
- 'develop'

jobs:
docker:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
name: Check out code

- uses: mr-smithers-excellent/docker-build-push@v6
name: Build & push Docker image
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
image: jfryy/qq
tags: v1, latest
multiPlatform: true
registry: registry.hub.docker.com
dockerfile: Dockerfile
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Determine push branch
id: check_branch
run: echo "::set-output name=push_branch::${GITHUB_REF##*/}"

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
jfryy/qq:${{ steps.check_branch.outputs.push_branch }}-${{ github.sha }}
jfryy/qq:${{ steps.check_branch.outputs.push_branch }}-latest
32 changes: 25 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
FROM golang:1.22 as builder
FROM debian:buster as builder

WORKDIR /qq
RUN apt-get update \
&& apt-get install -y \
wget \
gnupg \
ca-certificates \
git \
jq \
make \
&& rm -rf /var/lib/apt/lists/*

RUN wget -O /tmp/go.tar.gz https://golang.org/dl/go1.22.4.linux-amd64.tar.gz \
&& tar -C /usr/local -xzf /tmp/go.tar.gz \
&& rm /tmp/go.tar.gz

ENV PATH="/usr/local/go/bin:${PATH}"
ENV GOPATH="/go"
ENV GOBIN="/go/bin"
WORKDIR /app
COPY . .
ENV CGO_ENABLED 0
RUN make build
RUN apt update -y && apt install jq -y && make test

FROM gcr.io/distroless/static:debug

COPY --from=builder /qq/bin/qq /
ENTRYPOINT ["/qq"]
FROM gcr.io/distroless/static:nonroot
WORKDIR /qq
COPY --from=builder /app/bin/qq ./qq

ENTRYPOINT ["./qq"]
CMD ["./qq", "--help"]

0 comments on commit 2d48fcb

Please sign in to comment.