Skip to content

Commit a7b7da1

Browse files
committed
update docker file for product catalog
1 parent 88c5c74 commit a7b7da1

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/productcatalogservice/Dockerfile

+18-11
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,31 @@
33

44
FROM registry.ddbuild.io/images/mirror/golang:1.22-alpine AS builder
55

6+
67
WORKDIR /usr/src/app/
78

89
RUN apk update \
910
&& apk add --no-cache make protobuf-dev
1011

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 \
12+
COPY ./src/productcatalogservice/go.sum tools/go.sum
13+
COPY ./src/productcatalogservice/go.mod tools/go.mod
14+
COPY ./src/productcatalogservice/tools.go tools/tools.go
15+
16+
WORKDIR /usr/src/app/tools
17+
18+
RUN go mod download \
1619
&& go list -e -f '{{range .Imports}}{{.}} {{end}}' tools.go | CGO_ENABLED=0 xargs go install -mod=readonly
1720

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/ ./
21+
WORKDIR /usr/src/app/
22+
23+
COPY ./src/productcatalogservice ./src/productcatalogservice
24+
COPY ./pb ./pb
25+
26+
RUN protoc -I ./pb ./pb/demo.proto --go_out=./src/productcatalogservice --go-grpc_out=./src/productcatalogservice
27+
28+
WORKDIR /usr/src/app/src/productcatalogservice
29+
RUN go build -ldflags "-s -w" -o /go/bin/productcatalogservice/ ./
30+
2431

2532

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

0 commit comments

Comments
 (0)