-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
45 lines (33 loc) · 880 Bytes
/
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
# syntax=docker/dockerfile:1
##
## Build stage.
##
FROM golang:1.20-alpine AS build
## Install required libraries and tools
RUN apk add protoc grpc protobuf build-base git
RUN go install google.golang.org/protobuf/cmd/[email protected]
RUN go install google.golang.org/grpc/cmd/[email protected]
RUN go install github.com/favadi/protoc-go-inject-tag@latest
ENV GO111MODULE=on
WORKDIR /app
# Download dependencies
COPY go.mod ./
COPY go.sum ./
RUN go mod download
# Copy app
COPY . .
# Generate protobuf files
RUN go generate
# build the actual binary
RUN GOOS=linux GOARCH=amd64 go build -ldflags "-linkmode external -s -w -extldflags '-static'" -trimpath -o entry
##
## Deploy stage
##
FROM scratch
# copy the prebuilt image
WORKDIR /
COPY --from=build /app/entry /entry
# expose default listen port
EXPOSE 9999
# set app as startup app
ENTRYPOINT ["/entry"]