Skip to content

Commit 57dbf2b

Browse files
committed
Trying updated dockerfile
1 parent 5efe90d commit 57dbf2b

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

src/productcatalogservice/Dockerfile

+16-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,22 @@ FROM registry.ddbuild.io/images/mirror/golang:1.22-alpine AS builder
66

77
WORKDIR /usr/src/app/
88

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

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

src/productcatalogservice/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/Datadog/opentelemetry-demo/src/productcatalogservice
1+
module github.com/opentelemetry/opentelemetry-demo/src/productcatalogservice
22

33
go 1.22.0
44

src/productcatalogservice/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ import (
3333
sdktrace "go.opentelemetry.io/otel/sdk/trace"
3434
"go.opentelemetry.io/otel/trace"
3535

36-
pb "github.com/Datadog/opentelemetry-demo/src/productcatalogservice/genproto/oteldemo"
3736
otelhooks "github.com/open-feature/go-sdk-contrib/hooks/open-telemetry/pkg"
3837
flagd "github.com/open-feature/go-sdk-contrib/providers/flagd/pkg"
3938
"github.com/open-feature/go-sdk/openfeature"
39+
pb "github.com/opentelemetry/opentelemetry-demo/src/productcatalogservice/genproto/oteldemo"
4040
"google.golang.org/grpc"
4141
"google.golang.org/grpc/codes"
4242
"google.golang.org/grpc/credentials/insecure"

0 commit comments

Comments
 (0)