Skip to content

Commit

Permalink
Merge pull request #15 from depot/docker-container
Browse files Browse the repository at this point in the history
Build Docker container for CLI
  • Loading branch information
jacobwgillespie authored Apr 7, 2022
2 parents 8650df0 + 9c40e9c commit 1abf565
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,33 @@ jobs:
with:
version: 1.6.3
args: build --rm-dist --snapshot

package:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/metadata-action@v3
id: meta
with:
images: ghcr.io/depot/cli
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v2
with:
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM --platform=$BUILDPLATFORM golang:1.18 AS build
WORKDIR /src
ARG TARGETARCH
RUN mkdir /out
RUN \
--mount=target=. \
--mount=target=/go/pkg/mod,type=cache \
GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -o /out/ ./cmd/...

FROM --platform=$TARGETPLATFORM ubuntu:20.04

COPY --from=build /out/depot /usr/bin/depot
ENTRYPOINT ["/usr/bin/depot"]

0 comments on commit 1abf565

Please sign in to comment.