From 3cf69aae23cd37beb52e208b6204b80bea380eb4 Mon Sep 17 00:00:00 2001 From: Clavin June Date: Fri, 3 Dec 2021 17:32:36 +0700 Subject: [PATCH] optimize Dockerfile Signed-off-by: Clavin June --- .dockerignore | 1 + .github/workflows/ci.yml | 3 ++- .goreleaser.yml | 2 ++ Dockerfile | 9 ++------- Makefile | 5 ++++- main.go | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.dockerignore b/.dockerignore index a77385d..4805836 100644 --- a/.dockerignore +++ b/.dockerignore @@ -16,6 +16,7 @@ .golangci.yml .goreleaser.yml CNAME +Dockerfile LICENSE Makefile tools.mk diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c648dac..5decfc0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: - uses: actions/setup-go@v2 with: - go-version: 1.17.3 + go-version: 1.17.4 - uses: actions/cache@v2 with: @@ -54,6 +54,7 @@ jobs: - if: startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push' run: | + mkdir -p src/ brew install upx make ci/release diff --git a/.goreleaser.yml b/.goreleaser.yml index ef6ccec..ba7ca2b 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -48,6 +48,8 @@ dockers: - "ghcr.io/clavinjune/serve:{{ .ShortCommit }}" - "ghcr.io/clavinjune/serve:latest" skip_push: auto + extra_files: + - src/ changelog: sort: asc filters: diff --git a/Dockerfile b/Dockerfile index bd48852..2ec5cba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,12 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.17.3-alpine3.14 as builder -LABEL builder="true" -RUN mkdir -p /build/src - -FROM gcr.io/distroless/static +FROM gcr.io/distroless/static:latest WORKDIR /app -COPY --from=builder /build/src src -COPY serve . +COPY . . ENTRYPOINT [ "/app/serve", "-r", "/app/src" ] diff --git a/Makefile b/Makefile index 93766cc..5f14ebf 100644 --- a/Makefile +++ b/Makefile @@ -63,4 +63,7 @@ fmt: @go run $(licenser) apply -r "ClavinJune/serve" 2> /dev/null release: - @GITHUB_TOKEN="${GITHUB_PAT}" go run $(releaser) release --rm-dist \ No newline at end of file + @GITHUB_TOKEN="${GITHUB_PAT}" go run $(releaser) release --rm-dist + +snapshot: + @GITHUB_TOKEN="${GITHUB_PAT}" go run $(releaser) release --rm-dist --snapshot \ No newline at end of file diff --git a/main.go b/main.go index b6daff4..52bd192 100644 --- a/main.go +++ b/main.go @@ -31,7 +31,7 @@ import ( ) const ( - version string = "v0.3.6" + version string = "v0.3.7" ) var (