docker alpine->google-distroless

This commit is contained in:
Jaime Pillora
2023-01-27 23:02:06 +11:00
parent fbc8ad9731
commit 4246b649e1
2 changed files with 28 additions and 28 deletions
+21 -20
View File
@@ -10,35 +10,33 @@ jobs:
name: Test
strategy:
matrix:
go-version: [1.13.x, 1.14.x, 1.15.x, 1.16.x, 1.17.x, 1.18.x, 1.19.x]
go-version: [1.16.x, 1.17.x, 1.18.x, 1.19.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v1
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3
- name: Build
run: go build -v .
- name: Test
run: go test -v ./...
env:
GODEBUG: x509ignoreCN=0
# ================
# RELEASE JOB
# RELEASE JOBS
# runs after a success test
# only runs on push "v*" tag
# ================
release:
name: Release
release_binaries:
name: Release Binaries
needs: test
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3
- name: goreleaser
if: success()
uses: docker://goreleaser/goreleaser:latest
@@ -46,6 +44,14 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: release --config .github/goreleaser.yml
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@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
@@ -58,21 +64,16 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
uses: docker/metadata-action@v4
with:
images: jpillora/chisel
tag-latest: true
# Outputs:
# jpillora/chisel:1.2.3
# jpillora/chisel:1.2
# jpillora/chisel:1
# jpillora/chisel:latest
tag-semver: |
{{version}}
{{major}}.{{minor}}
{{major}}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/386,linux/arm/v7,linux/arm/v6
+7 -8
View File
@@ -1,17 +1,16 @@
# build stage
FROM golang:alpine AS build-env
FROM golang:1.19 as build
LABEL maintainer="dev@jpillora.com"
RUN apk update
RUN apk add git
ENV CGO_ENABLED 0
ADD . /src
WORKDIR /src
RUN go mod download
RUN go build \
-ldflags "-X github.com/jpillora/chisel/share.BuildVersion=$(git describe --abbrev=0 --tags)" \
-o chisel
# container stage
FROM alpine
RUN apk update && apk add --no-cache ca-certificates
# run stage
FROM gcr.io/distroless/static-debian11
WORKDIR /app
COPY --from=build-env /src/chisel /app/chisel
ENTRYPOINT ["/app/chisel"]
CMD ["/app"]
COPY --from=build /src/chisel /app/chisel
ENTRYPOINT ["/app/chisel"]