-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
94 lines (63 loc) · 1.89 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
###########
# BUILDER #
###########
FROM golang:1.18 AS builder
RUN apt-get update \
&& apt-get install -y curl protobuf-compiler \
&& rm -rf /var/lib/apt/lists/*
RUN go install github.com/go-task/task/v3/cmd/[email protected]
RUN go install google.golang.org/protobuf/cmd/[email protected]
RUN go install google.golang.org/grpc/cmd/[email protected]
WORKDIR /tmp/go
COPY go.mod go.sum ./
RUN go mod download
WORKDIR /go
###################
# BUILDING STAGES #
###################
FROM builder AS api-gateway-build
WORKDIR /project
COPY . .
RUN task api_gateway:build
FROM builder AS order-service-build
WORKDIR /project
COPY . .
RUN task order_service:build
FROM builder AS payment-service-build
WORKDIR /project
COPY . .
RUN task payment_service:build
FROM builder AS stock-service-build
WORKDIR /project
COPY . .
RUN task stock_service:build
################
# FINAL STAGES #
################
FROM alpine:3.15 AS api-gateway
EXPOSE 8080
RUN apk add --no-cache dumb-init
WORKDIR /app
COPY --from=api-gateway-build /project/out/api-gateway .
# Dumb init necessary to claim the PID 1 and allow Fiber to manage the process IDs
# See: https://github.com/gofiber/fiber/issues/1036
ENTRYPOINT ["/usr/bin/dumb-init", "--", "sh", "-c"]
CMD ["/app/api-gateway --prefork --config-file=config/config.yaml"]
FROM alpine:3.15 AS order-service
EXPOSE 50000
WORKDIR /app
COPY --from=order-service-build /project/out/order-service .
ENTRYPOINT ["/app/order-service"]
CMD ["--config-file=config/config.yaml"]
FROM alpine:3.15 AS payment-service
EXPOSE 50001
WORKDIR /app
COPY --from=payment-service-build /project/out/payment-service .
ENTRYPOINT ["/app/payment-service"]
CMD ["--config-file=config/config.yaml"]
FROM alpine:3.15 AS stock-service
EXPOSE 50002
WORKDIR /app
COPY --from=stock-service-build /project/out/stock-service .
ENTRYPOINT ["/app/stock-service"]
CMD ["--config-file=config/config.yaml"]