-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
59 lines (42 loc) · 1.75 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
FROM golang:1.21 AS builder
ARG GOLANGCI_VERSION=v1.47.2
ARG COVERAGE_THRESH_PCT=81
ENV GO111MODULE=on \
CGO_ENABLED=0
# Get test coverage tool and protobuf codegen
# RUN go install github.com/klmitch/[email protected] \
# && go install github.com/bufbuild/buf/cmd/[email protected] \
# && go install google.golang.org/protobuf/cmd/[email protected] \
# && go install google.golang.org/grpc/cmd/[email protected]
RUN go install github.com/klmitch/[email protected] \
&& go install github.com/bufbuild/buf/cmd/[email protected] \
&& go install google.golang.org/protobuf/cmd/[email protected] \
&& go install google.golang.org/grpc/cmd/[email protected]
WORKDIR /build
# Copy the code necessary to build the application
# Hoovering in everything here doesn't matter -
# we're going to discard this intermediate image later anyway
# and just copy over the resulting binary
COPY . .
RUN go mod tidy
# Vendor modules here so that subsequent steps don't
# re-fetch, and just use the vendored versions
RUN go mod vendor
# Let's create a /dist folder containing just the files necessary for runtime.
# Later, it will be copied as the / (root) of the output image.
RUN mkdir /dist
# Run linters
#Lint/gen protobuf code
WORKDIR /build/proto
RUN buf lint && buf generate || echo 'TODO fix service proto'
WORKDIR /build
# Run tests
RUN go test --coverprofile cover.out ./attributes ./pdp
# Test coverage
RUN overcover --coverprofile cover.out ./attributes ./pdp --threshold ${COVERAGE_THRESH_PCT}
# Build the application
RUN go build -o /dist/access-pdp-grpc-server
# Create the minimal runtime image
FROM scratch AS emptyfinal
COPY --chown=0:0 --from=builder /dist/access-pdp-grpc-server /access-pdp-grpc-server
ENTRYPOINT ["/access-pdp-grpc-server"]