generated from twin-te/grpc-ts-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
31 lines (23 loc) · 817 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
# Create executable file.
FROM golang:1.20-bullseye as deploy-builder
WORKDIR /app
COPY go.mod go.sum Makefile ./
COPY server/pb/UserService.proto ./server/pb/
RUN apt-get -y update \
&& apt-get -y upgrade \
&& apt-get -y install protobuf-compiler \
&& go mod download \
&& go install google.golang.org/protobuf/cmd/[email protected] \
&& go install google.golang.org/grpc/cmd/[email protected] \
&& make protoc
COPY . .
RUN go build -trimpath -ldflags "-w -s" -o app
# Deploy
FROM debian:bullseye-slim as deploy
RUN apt-get -y update \
&& apt-get -y install curl tar \
&& curl -L https://github.com/golang-migrate/migrate/releases/download/v4.15.2/migrate.linux-amd64.tar.gz | tar xvz \
&& mv ./migrate /usr/local/bin
COPY --from=deploy-builder /app/app .
EXPOSE 50051
CMD ["./app"]