Skip to content

Commit

Permalink
Merge branch 'main' into paymentservice-checkoutservice-introduce-new…
Browse files Browse the repository at this point in the history
…-featureflags
  • Loading branch information
julianocosta89 committed Mar 14, 2024
2 parents 255ce29 + 95f8f29 commit 32f5597
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
28 changes: 17 additions & 11 deletions src/checkoutservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
# SPDX-License-Identifier: Apache-2.0


FROM golang:1.22.0-alpine AS builder
RUN apk update && apk add --no-cache make protobuf-dev
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
FROM golang:1.22-alpine AS builder

WORKDIR /usr/src/app/

COPY ./src/checkoutservice/ ./
COPY ./pb/ ./pb

RUN protoc -I ./pb ./pb/demo.proto --go_out=./ --go-grpc_out=./
RUN go build -o /go/bin/checkoutservice/

# -----------------------------------------------------------------------------
RUN apk update \
&& apk add --no-cache make protobuf-dev

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=./src/checkoutservice/go.sum,target=go.sum \
--mount=type=bind,source=./src/checkoutservice/go.mod,target=go.mod \
--mount=type=bind,source=./src/checkoutservice/tools.go,target=tools.go \
go mod download \
&& go list -e -f '{{range .Imports}}{{.}} {{end}}' tools.go | CGO_ENABLED=0 xargs go install -mod=readonly

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=bind,rw,source=./src/checkoutservice,target=. \
--mount=type=bind,rw,source=./pb,target=./pb \
protoc -I ./pb ./pb/demo.proto --go_out=./ --go-grpc_out=./ \
&& go build -ldflags "-s -w" -o /go/bin/checkoutservice/ ./

FROM alpine

Expand Down
30 changes: 17 additions & 13 deletions src/productcatalogservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@
# SPDX-License-Identifier: Apache-2.0


FROM golang:1.22.0-alpine AS builder
RUN apk update && apk add --no-cache make protobuf-dev
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
FROM golang:1.22-alpine AS builder

WORKDIR /usr/src/app/

RUN apk add build-base protobuf-dev protoc
COPY ./pb/ ./pb

RUN protoc -I ./pb ./pb/demo.proto --go_out=./ --go-grpc_out=./

COPY ./src/productcatalogservice/ ./
RUN go build -o /go/bin/productcatalogservice/

# -----------------------------------------------------------------------------
RUN apk update \
&& apk add --no-cache make protobuf-dev

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=./src/productcatalogservice/go.sum,target=go.sum \
--mount=type=bind,source=./src/productcatalogservice/go.mod,target=go.mod \
--mount=type=bind,source=./src/productcatalogservice/tools.go,target=tools.go \
go mod download \
&& go list -e -f '{{range .Imports}}{{.}} {{end}}' tools.go | CGO_ENABLED=0 xargs go install -mod=readonly

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=bind,rw,source=./src/productcatalogservice,target=. \
--mount=type=bind,rw,source=./pb,target=./pb \
protoc -I ./pb ./pb/demo.proto --go_out=./ --go-grpc_out=./ \
&& go build -ldflags "-s -w" -o /go/bin/productcatalogservice/ ./

FROM alpine AS release

Expand Down

0 comments on commit 32f5597

Please sign in to comment.