-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Improve Docker: use GoReleaser for images #584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,8 @@ | ||
| # build stage | ||
| FROM golang:alpine AS build | ||
| RUN apk update && apk add git | ||
| ADD . /src | ||
| WORKDIR /src | ||
| ENV CGO_ENABLED=0 | ||
| RUN go build \ | ||
| -ldflags "-X github.com/jpillora/chisel/share.BuildVersion=$(git describe --abbrev=0 --tags)" \ | ||
| -o /tmp/bin | ||
| # run stage | ||
| FROM alpine:3 AS certs | ||
| RUN apk add --no-cache ca-certificates | ||
|
|
||
| FROM scratch | ||
| LABEL maintainer="dev@jpillora.com" | ||
| COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
| WORKDIR /app | ||
| COPY --from=build /tmp/bin /app/bin | ||
| ENTRYPOINT ["/app/bin"] | ||
| COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
| COPY chisel /app/bin | ||
| ENTRYPOINT ["/app/bin"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,3 +59,97 @@ changelog: | |
| exclude: | ||
| - "^docs:" | ||
| - "^test:" | ||
|
|
||
| dockers: | ||
| - image_templates: | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-amd64" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-amd64" | ||
| use: buildx | ||
| dockerfile: .github/Dockerfile | ||
| build_flag_templates: | ||
| - "--platform=linux/amd64" | ||
| goarch: amd64 | ||
|
|
||
| - image_templates: | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-arm64" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-arm64" | ||
| use: buildx | ||
| dockerfile: .github/Dockerfile | ||
| build_flag_templates: | ||
| - "--platform=linux/arm64" | ||
| goarch: arm64 | ||
|
|
||
| - image_templates: | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-armv7" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-armv7" | ||
| use: buildx | ||
| dockerfile: .github/Dockerfile | ||
| build_flag_templates: | ||
| - "--platform=linux/arm/v7" | ||
| goarch: arm | ||
| goarm: "7" | ||
|
|
||
| - image_templates: | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-armv6" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-armv6" | ||
| use: buildx | ||
| dockerfile: .github/Dockerfile | ||
| build_flag_templates: | ||
| - "--platform=linux/arm/v6" | ||
| goarch: arm | ||
| goarm: "6" | ||
|
|
||
| - image_templates: | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-386" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-386" | ||
| use: buildx | ||
| dockerfile: .github/Dockerfile | ||
| build_flag_templates: | ||
| - "--platform=linux/386" | ||
| goarch: "386" | ||
|
|
||
| - image_templates: | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-ppc64le" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-ppc64le" | ||
| use: buildx | ||
| dockerfile: .github/Dockerfile | ||
| build_flag_templates: | ||
| - "--platform=linux/ppc64le" | ||
| goarch: ppc64le | ||
|
|
||
| docker_manifests: | ||
| - name_template: "ghcr.io/jpillora/chisel:{{ .Tag }}" | ||
| image_templates: | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-amd64" | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-arm64" | ||
|
||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-armv7" | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-armv6" | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-386" | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-ppc64le" | ||
|
|
||
| - name_template: "ghcr.io/jpillora/chisel:latest" | ||
| image_templates: | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-amd64" | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-arm64" | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-armv7" | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-armv6" | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-386" | ||
| - "ghcr.io/jpillora/chisel:{{ .Tag }}-ppc64le" | ||
|
||
|
|
||
| - name_template: "docker.io/jpillora/chisel:{{ .Tag }}" | ||
| image_templates: | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-amd64" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-arm64" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-armv7" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-armv6" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-386" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-ppc64le" | ||
|
|
||
| - name_template: "docker.io/jpillora/chisel:latest" | ||
| image_templates: | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-amd64" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-arm64" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-armv7" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-armv6" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-386" | ||
| - "docker.io/jpillora/chisel:{{ .Tag }}-ppc64le" | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,6 @@ name: CI | |||||
| on: | ||||||
| pull_request: {} | ||||||
| push: {} | ||||||
| permissions: write-all | ||||||
| jobs: | ||||||
| # ================ | ||||||
| # BUILD AND TEST JOB | ||||||
|
|
@@ -29,64 +28,47 @@ jobs: | |||||
| - name: Test | ||||||
| run: go test -v ./... | ||||||
| # ================ | ||||||
| # RELEASE BINARIES (on push "v*" tag) | ||||||
| # RELEASE (on push "v*" tag) | ||||||
| # Builds binaries, packages, and multi-arch Docker images via GoReleaser | ||||||
| # ================ | ||||||
| release_binaries: | ||||||
| name: Release Binaries | ||||||
| release: | ||||||
| name: Release | ||||||
| needs: test | ||||||
| if: startsWith(github.ref, 'refs/tags/v') | ||||||
| runs-on: ubuntu-latest | ||||||
| permissions: | ||||||
| contents: write | ||||||
| packages: write | ||||||
| steps: | ||||||
| - name: Check out code | ||||||
| - name: Checkout | ||||||
| uses: actions/checkout@v5 | ||||||
| with: | ||||||
| fetch-depth: 0 | ||||||
| - name: goreleaser | ||||||
| if: success() | ||||||
| uses: docker://goreleaser/goreleaser:latest | ||||||
| env: | ||||||
| GITHUB_USER: ${{ github.repository_owner }} | ||||||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||
| GOTOOLCHAIN: auto | ||||||
| - name: Set up Go | ||||||
| uses: actions/setup-go@v6 | ||||||
| with: | ||||||
| args: release --config .github/goreleaser.yml | ||||||
| # ================ | ||||||
| # RELEASE DOCKER IMAGES (on push "v*" tag) | ||||||
| # ================ | ||||||
| release_docker: | ||||||
| name: Release Docker Images | ||||||
| needs: test | ||||||
| if: startsWith(github.ref, 'refs/tags/v') | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - name: Check out code | ||||||
| uses: actions/checkout@v5 | ||||||
| go-version: stable | ||||||
| cache: true | ||||||
| - name: Set up QEMU | ||||||
| uses: docker/setup-qemu-action@v3 | ||||||
| - name: Set up Docker Buildx | ||||||
| uses: docker/setup-buildx-action@v3 | ||||||
| - name: Login to DockerHub | ||||||
| - name: Login to GHCR | ||||||
| uses: docker/login-action@v3 | ||||||
| with: | ||||||
| registry: ghcr.io | ||||||
| username: ${{ github.repository_owner }} | ||||||
| password: ${{ secrets.GITHUB_TOKEN }} | ||||||
| - name: Login to Docker Hub | ||||||
| uses: docker/login-action@v3 | ||||||
| with: | ||||||
| username: jpillora | ||||||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||||
| - name: Docker meta | ||||||
| id: meta | ||||||
| uses: docker/metadata-action@v5 | ||||||
| with: | ||||||
| images: jpillora/chisel | ||||||
| tags: | | ||||||
| type=semver,pattern={{version}} | ||||||
| type=semver,pattern={{major}}.{{minor}} | ||||||
| type=semver,pattern={{major}} | ||||||
| - name: Build and push | ||||||
| uses: docker/build-push-action@v6 | ||||||
| - name: Run GoReleaser | ||||||
| uses: goreleaser/goreleaser-action@v6 | ||||||
| with: | ||||||
| context: . | ||||||
| file: .github/Dockerfile | ||||||
| platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/386,linux/arm/v7,linux/arm/v6 | ||||||
| push: true | ||||||
| tags: ${{ steps.meta.outputs.tags }} | ||||||
| labels: ${{ steps.meta.outputs.labels }} | ||||||
| cache-from: type=gha | ||||||
| cache-to: type=gha,mode=max | ||||||
| distribution: goreleaser | ||||||
| version: latest | ||||||
|
||||||
| version: latest | |
| version: v2.12.7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker image tags/manifests are templated with
{{ .Tag }}, which will include the leadingvfrom git tags (e.g.,v1.2.3). This differs from the prior workflow’s semver tags (e.g.,1.2.3) and from the binary BuildVersion which uses{{ .Version }}. If you want to preserve existing Docker tag semantics, switch these templates to use{{ .Version }}(and update all related templates consistently).