Skip to content

Commit

Permalink
Add support for Docker images (#7)
Browse files Browse the repository at this point in the history
* Add Dockerfile based on Distroless

* Add Docker to build workflow

* Minor tweak

* Update .github/workflows/build.yml

Co-authored-by: taoky <[email protected]>

---------

Co-authored-by: taoky <[email protected]>
  • Loading branch information
stevapple and taoky authored Aug 12, 2024
1 parent 0438321 commit 679ac66
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,34 @@ jobs:
sshmux
config.example.json
sshmux.service
docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Compute Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/ustc-vlab/sshmux
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
if: startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
push: ${{ startsWith(github.ref, 'refs/tags/') }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.22 AS build

WORKDIR /go/src/app
COPY . .

RUN go mod download
RUN CGO_ENABLED=0 go build -o /go/bin/sshmux

FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=build /go/bin/sshmux /
CMD ["/sshmux"]

0 comments on commit 679ac66

Please sign in to comment.