From c172fa866dd696ad40ad4196e6b0a6832649af4a Mon Sep 17 00:00:00 2001 From: clabby Date: Tue, 10 Sep 2024 17:07:43 -0400 Subject: [PATCH] feat: Docker release --- .github/workflows/docker_release.yaml | 37 +++++++++++++++++++++++++++ Dockerfile.release | 20 +++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .github/workflows/docker_release.yaml create mode 100644 Dockerfile.release diff --git a/.github/workflows/docker_release.yaml b/.github/workflows/docker_release.yaml new file mode 100644 index 00000000..59167e30 --- /dev/null +++ b/.github/workflows/docker_release.yaml @@ -0,0 +1,37 @@ +name: Build and Publish Asterisc Images + +on: [workflow_dispatch, workflow_call, push] + +env: + REGISTRY: ghcr.io + +jobs: + build-pipelines: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + env: + IMAGE_NAME: ${{ github.repository }}/asterisc + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Authenticate with container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and Publish `asterisc` + uses: docker/build-push-action@v6 + with: + file: Dockerfile.release + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile.release b/Dockerfile.release new file mode 100644 index 00000000..00cff118 --- /dev/null +++ b/Dockerfile.release @@ -0,0 +1,20 @@ +FROM golang:1.21.1-alpine3.18 AS builder +WORKDIR /build +ARG ASTERISC_TAG + +# Copy the context into the container +ADD . . + +# Install deps +RUN apk add --no-cache git make bash + +# Clone and build Asterisc @ `ASTERISC_TAG` +RUN make && \ + cp rvgo/bin/asterisc /asterisc-bin + +FROM alpine:3.18 AS export + +RUN apk add --no-cache bash +SHELL ["/bin/bash", "-c"] + +COPY --from=builder /asterisc-bin /asterisc-bin