-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(server,worker): optimize Dockerfile
- Loading branch information
Showing
2 changed files
with
21 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
FROM golang:1.22-alpine AS build | ||
ARG GO_VERSION=1.22 | ||
ARG TAG=release | ||
ARG VERSION | ||
FROM golang:${GO_VERSION}-alpine AS build | ||
|
||
RUN apk add --update --no-cache git ca-certificates build-base fuse | ||
RUN CGO_ENABLED=0 go install github.com/googlecloudplatform/[email protected] | ||
# RUN CGO_ENABLED=0 go install github.com/googlecloudplatform/[email protected] | ||
|
||
WORKDIR /app | ||
|
||
RUN --mount=type=bind,source=worker/go.mod,target=go.mod \ | ||
--mount=type=bind,source=worker/go.sum,target=go.sum \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
go mod download | ||
|
||
COPY . /app/ | ||
|
||
RUN CGO_ENABLED=0 go build -tags "${TAG}" "-ldflags=-X main.version=${VERSION} -s -w -buildid=" -trimpath -o plateauview-worker ./worker | ||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
CGO_ENABLED=0 go build -tags "${TAG}" "-ldflags=-X main.version=${VERSION} -s -w -buildid=" -trimpath -o plateauview-worker ./worker | ||
|
||
FROM scratch | ||
|
||
|