Skip to content

Commit

Permalink
adding the first MS
Browse files Browse the repository at this point in the history
  • Loading branch information
leoporoli committed Jul 30, 2024
0 parents commit f998c0a
Show file tree
Hide file tree
Showing 90 changed files with 5,966 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cartservice/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.gitignore
Dockerfile
21 changes: 21 additions & 0 deletions src/cartservice/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# IDE
.vscode

# don't commit the service binary to vcs
cartservice
38 changes: 38 additions & 0 deletions src/cartservice/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM golang:1.19.0-alpine AS builder

# Set Go env
ENV CGO_ENABLED=0 GOOS=linux
WORKDIR /go/src/hipstershop

# Install dependencies
RUN apk --update --no-cache add ca-certificates make protoc

# Download grpc_health_probe
RUN GRPC_HEALTH_PROBE_VERSION=v0.4.11 && \
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

# Build Go binary
COPY Makefile go.mod go.sum ./
RUN go env -w GOPROXY=https://goproxy.io,direct/
RUN make init && go mod download
COPY . .
RUN make proto tidy

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

# Deployment container
FROM scratch

# 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

COPY --from=builder /etc/ssl/certs /etc/ssl/certs
COPY --from=builder /bin/grpc_health_probe /bin/
COPY --from=builder /go/src/hipstershop/cartservice /hipstershop/cartservice

ENTRYPOINT ["/hipstershop/cartservice"]
33 changes: 33 additions & 0 deletions src/cartservice/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
GOPATH:=$(shell go env GOPATH)

.PHONY: init
init:
@go get -u google.golang.org/protobuf/proto
@go install github.com/golang/protobuf/protoc-gen-go@latest
@go install github.com/go-micro/generator/cmd/protoc-gen-micro@latest

.PHONY: proto
proto:
@protoc --proto_path=. --micro_out=. --go_out=:. proto/cartservice.proto
@protoc --proto_path=. --micro_out=. --go_out=:. proto/health.proto


.PHONY: update
update:
@go get -u

.PHONY: tidy
tidy:
@go mod tidy

.PHONY: build
build:
@go build -o cartservice *.go

.PHONY: test
test:
@go test -v ./... -cover

.PHONY: docker
docker:
@docker build -t kurtosistech/obd-cartservice:latest .
Loading

0 comments on commit f998c0a

Please sign in to comment.