|
3 | 3 |
|
4 | 4 | FROM registry.ddbuild.io/images/mirror/golang:1.22-alpine AS builder
|
5 | 5 |
|
| 6 | + |
6 | 7 | WORKDIR /usr/src/app/
|
7 | 8 |
|
8 | 9 | RUN apk update \
|
9 | 10 | && apk add --no-cache make protobuf-dev
|
10 | 11 |
|
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 \ |
16 | 19 | && go list -e -f '{{range .Imports}}{{.}} {{end}}' tools.go | CGO_ENABLED=0 xargs go install -mod=readonly
|
17 | 20 |
|
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 | + |
24 | 31 |
|
25 | 32 |
|
26 | 33 | FROM registry.ddbuild.io/images/mirror/alpine:latest AS release
|
|
0 commit comments