Skip to content

Commit 88c5c74

Browse files
committed
update docker file
1 parent 6330a9b commit 88c5c74

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/productcatalogservice/Dockerfile

+15-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,20 @@ WORKDIR /usr/src/app/
88
RUN apk update \
99
&& apk add --no-cache make protobuf-dev
1010

11-
COPY ./src/productcatalogservice/ ./
12-
RUN go generate
13-
RUN go build -ldflags "-s -w" -o /go/bin/productcatalogservice/ ./
11+
RUN --mount=type=cache,target=/go/pkg/mod/ \
12+
--mount=type=bind,source=./src/productcatalogservice/go.sum,target=go.sum \
13+
--mount=type=bind,source=./src/productcatalogservice/go.mod,target=go.mod \
14+
--mount=type=bind,source=./src/productcatalogservice/tools.go,target=tools.go \
15+
go mod download \
16+
&& go list -e -f '{{range .Imports}}{{.}} {{end}}' tools.go | CGO_ENABLED=0 xargs go install -mod=readonly
17+
18+
RUN --mount=type=cache,target=/go/pkg/mod/ \
19+
--mount=type=cache,target=/root/.cache/go-build \
20+
--mount=type=bind,rw,source=./src/productcatalogservice,target=. \
21+
--mount=type=bind,rw,source=./pb,target=./pb \
22+
protoc -I ./pb ./pb/demo.proto --go_out=./ --go-grpc_out=./ \
23+
&& go build -ldflags "-s -w" -o /go/bin/productcatalogservice/ ./
24+
1425

1526
FROM registry.ddbuild.io/images/mirror/alpine:latest AS release
1627

@@ -20,4 +31,4 @@ COPY ./src/productcatalogservice/products/ ./products/
2031
COPY --from=builder /go/bin/productcatalogservice/ ./
2132

2233
EXPOSE ${PRODUCT_SERVICE_PORT}
23-
ENTRYPOINT [ "./productcatalogservice" ]
34+
ENTRYPOINT [ "./productcatalogservice" ]

0 commit comments

Comments
 (0)