-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
86 lines (65 loc) · 1.73 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
#
# GOLANG BUILDER
#
FROM golang:1.16 as golang-builder
LABEL builder=true
RUN mkdir -p /root/app
ADD ./gateway /root/app/gateway
WORKDIR /root/app/gateway
RUN go get -d -v ./...
RUN go build -o slice-gateway ./...
#
# NODE BUILDER
#
FROM node:16-bullseye-slim as node-builder
LABEL builder=true
RUN npm install --global pnpm@8
RUN mkdir -p /root/app/client
WORKDIR /root/app/client
ADD client/package.json client/pnpm-lock.yaml client/.npmrc ./
RUN pnpm install --frozen-lockfile
ADD client .
RUN NODE_ENV=production pnpm run build
#
# RUST BUILDER
#
FROM rust:1.61-slim-bullseye as rust-builder
LABEL builder=true
RUN mkdir -p /root/app
WORKDIR /root/app
RUN apt-get update \
&& apt-get install -y \
build-essential \
git \
libssl-dev \
pkgconf \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN cargo new --bin server --name slice-n-dice-server
WORKDIR ./server
ADD ./server/Cargo.lock ./server/Cargo.toml ./
RUN cargo build --release
ADD ./server .
RUN rm ./target/release/deps/*slice_n_dice_server*
RUN cargo build --release
#
# RUNNER
#
FROM debian:bullseye-slim as runner
RUN apt-get update \
&& apt-get install -y \
libssl1.1 \
supervisor \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir /root/app
WORKDIR /root/app
RUN mkdir -p /var/log/supervisor
COPY supervisord.conf supervisord.conf
COPY --from=node-builder /root/app/client/build ./public
COPY --from=rust-builder /root/app/server/target/release/slice-n-dice-server .
COPY --from=golang-builder /root/app/gateway/slice-gateway .
ENV GATEWAY_URL http://:8090
ENV SERVER_URL http://localhost:8091
ENV READ_URL http://localhost:8092
EXPOSE 8090
CMD ["supervisord", "-n", "-c", "/root/app/supervisord.conf"]