-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
43 lines (30 loc) · 875 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
# Base Image
FROM golang:1.21.4-alpine3.18 as base
# Working directory
WORKDIR /app
# Copy go.mod and go.sum files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy the source code
COPY . .
# Build the application
RUN go build -o server ./cmd/main.go
# Adding the grpc_health_probe
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.1 && \
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
# Create master image
FROM alpine AS master
# Working directory
WORKDIR /app
# Copy grpc_heath_prob
COPY --from=base /bin/grpc_health_probe ./
# Copy execute file
COPY --from=base /app/server ./
# Set ENV to production
ENV GO_ENV production
# Expose port 3004
EXPOSE 3004
# Run the application
CMD ["./server"]