Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Proto Files for Checkout Service - GoLang #116

Merged
merged 2 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ services:
# CheckoutService
checkoutservice:
build:
context: ./src/checkoutservice
context: ./
dockerfile: ./src/checkoutservice/Dockerfile
ports:
- "${CHECKOUT_SERVICE_PORT}"
environment:
- PORT=${CHECKOUT_SERVICE_PORT}
- CHECKOUT_SERVICE_PORT
- CART_SERVICE_ADDR
- CURRENCY_SERVICE_ADDR
- EMAIL_SERVICE_ADDR
Expand All @@ -74,6 +75,13 @@ services:
- SHIPPING_SERVICE_ADDR
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
- OTEL_RESOURCE_ATTRIBUTES=service.name=checkoutservice
depends_on:
- cartservice
- currencyservice
- emailservice
- paymentservice
- productcatalogservice
- shippingservice

# CurrencyService
currencyservice:
Expand Down
1 change: 0 additions & 1 deletion src/checkoutservice/.dockerignore

This file was deleted.

41 changes: 18 additions & 23 deletions src/checkoutservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.17.7-alpine as builder
RUN apk add --no-cache ca-certificates git
RUN apk add build-base
WORKDIR /src
FROM golang:1.17.7-alpine AS builder
RUN apk add build-base protoc
WORKDIR /usr/src/app/

# restore dependencies
COPY go.mod go.sum ./
# Restore dependencies
COPY ./src/checkoutservice/ ./
COPY ./pb/ ./proto/
RUN go mod download
RUN go get google.golang.org/protobuf/cmd/protoc-gen-go
RUN go get google.golang.org/grpc/cmd/protoc-gen-go-grpc

COPY . .
# Build executable
RUN protoc -I ./proto/ ./proto/demo.proto --go_out=./ --go-grpc_out=./
RUN go build -o /go/bin/checkoutservice/ ./

# Skaffold passes in debug-oriented compiler flags
ARG SKAFFOLD_GO_GCFLAGS
RUN go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o /checkoutservice .
# -----------------------------------------------------------------------------

FROM alpine as release
RUN apk add --no-cache ca-certificates
RUN GRPC_HEALTH_PROBE_VERSION=v0.4.7 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe
WORKDIR /src
COPY --from=builder /checkoutservice /src/checkoutservice
FROM alpine

# Definition of this variable is used by 'skaffold debug' to identify a golang binary.
# Default behavior - a failure prints a stack trace for the current goroutine.
# See https://golang.org/pkg/runtime/
ENV GOTRACEBACK=single
WORKDIR /usr/src/app/

EXPOSE 5050
ENTRYPOINT ["/src/checkoutservice"]
COPY --from=builder /go/bin/checkoutservice/ ./

EXPOSE ${CHECKOUT_SERVICE_PORT}
ENTRYPOINT [ "./checkoutservice" ]
Loading