Skip to content

Commit

Permalink
Merge pull request #2700 from vdice/feat/spin-docker-image
Browse files Browse the repository at this point in the history
feat(docker): add spin cli Dockerfiles; add build/push to release.yml
  • Loading branch information
vdice authored Aug 20, 2024
2 parents 4b33730 + e34325a commit e0e39a9
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
git

ARG TARGETARCH
ARG TARGETOS
COPY spin-${TARGETOS}-${TARGETARCH} /usr/local/bin/spin

ENTRYPOINT [ "/usr/local/bin/spin" ]
7 changes: 7 additions & 0 deletions .github/distroless.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM gcr.io/distroless/static-debian12

ARG TARGETARCH
ARG TARGETOS
COPY spin-static-${TARGETOS}-${TARGETARCH} /usr/local/bin/spin

ENTRYPOINT [ "/usr/local/bin/spin" ]
77 changes: 77 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,80 @@ jobs:
repository: fermyon/homebrew-tap
event-type: spin-release
client-payload: '{"version": "${{ github.ref_name }}"}'

docker:
runs-on: "ubuntu-20.04"
needs: [build-and-sign, build-spin-static]
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
strategy:
matrix:
config:
- { dockerfile: "Dockerfile", tag-suffix: "" }
- { dockerfile: "distroless.Dockerfile", tag-suffix: "-distroless" }
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup version info
id: version
run: |
if [[ "${{ startsWith(github.ref, 'refs/tags/v') }}" == "true" ]]; then
echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "version=canary" >> $GITHUB_OUTPUT
fi
- name: download release assets
uses: actions/download-artifact@v3
with:
name: spin

- name: extract binaries
shell: bash
run: |
if [[ "${{ matrix.config.tag-suffix }}" == "-distroless" ]]; then
static="-static"
fi
tar xvf spin-${{ steps.version.outputs.version }}${static}-linux-amd64.tar.gz
mv spin spin${static}-linux-amd64
tar xvf spin-${{ steps.version.outputs.version }}${static}-linux-aarch64.tar.gz
# Note: here we s/aarch64/arm64 to conform to Docker's TARGETARCH standards
mv spin spin${static}-linux-arm64
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and Push
uses: docker/build-push-action@v6
with:
context: .
file: .github/${{ matrix.config.dockerfile }}
push: true
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}${{ matrix.config.tag-suffix }}

0 comments on commit e0e39a9

Please sign in to comment.