-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
111 lines (84 loc) · 2.6 KB
/
Dockerfile
File metadata and controls
111 lines (84 loc) · 2.6 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#
# GOLANG BUILDER
#
FROM golang:1.21-bookworm 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 rasasa-gateway ./...
#
# NODE BUILDER
#
FROM node:20-bookworm-slim AS node-builder
LABEL builder=true
RUN apt-get update \
&& apt-get install -y build-essential \
&& rm -rf /var/lib/apt/lists/*
RUN npm install --location=global pnpm@8
ENV PNPM_HOME="/usr/local/share/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN bash -c "SHELL=/bin/bash pnpm setup" # Setups pnpm with bash because it really wants to be in add random stuff to .bashrc
RUN mkdir -p /root/app/client
WORKDIR /root/app/client
ADD client/.npmrc client/package.json client/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
ADD client .
RUN pnpm run lint
RUN NODE_ENV=production pnpm run build
#
# RUST BUILDER
#
FROM rust:1.74-slim-bookworm AS rust-builder
LABEL builder=true
RUN mkdir -p /root/app
WORKDIR /root/app
RUN apt-get update && \
apt-get install -y \
build-essential \
cmake \
curl \
file \
git \
libpq-dev \
libssl-dev \
pkgconf \
xutils-dev \
ca-certificates
RUN cargo new --bin server --name rasasa-server
WORKDIR ./server
ADD ./server/Cargo.lock ./server/Cargo.toml ./
RUN cargo build --release
ADD ./server .
RUN rm ./target/release/deps/rasasa_server*
RUN cargo build --release
#
# RUNNER
#
FROM node:20-bookworm-slim AS runner
RUN apt-get update \
&& apt-get install -y git libpq5 \
&& rm -rf /var/lib/apt/lists/*
RUN npm install --location=global pnpm@8
RUN groupadd -r runner && useradd -m -r -g runner runner
USER runner
ENV PNPM_HOME="/home/runner/.local/share/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN bash -c "SHELL=/bin/bash pnpm setup" # Setups pnpm with bash because it really wants to be in add random stuff to .bashrc
RUN pnpm install --global concurrently
RUN mkdir -p /home/runner/app/read-server
WORKDIR /home/runner/app/read-server
ADD read-server/.npmrc read-server/package.json read-server/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod
ADD ./read-server .
WORKDIR /home/runner/app
# ADD ./Procfile .
COPY --from=node-builder /root/app/client/dist ./public
COPY --from=rust-builder /root/app/server/target/release/rasasa-server .
COPY --from=golang-builder /root/app/gateway/rasasa-gateway .
ENV GATEWAY_URL http://:8090
ENV SERVER_URL http://localhost:8091
ENV READ_URL http://localhost:8092
EXPOSE 8090
CMD concurrently -n 'Gateway,Server,Read' -c 'yellow,cyan,magenta' --kill-others './rasasa-gateway' './rasasa-server' '(cd read-server && pnpm start)'