-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.prod
94 lines (66 loc) · 2.09 KB
/
Dockerfile.prod
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
FROM oven/bun:1.2.2 AS bun
FROM rust:1.84.1-slim-bookworm AS rust
FROM debian:bookworm-slim AS debian
# =======================================
FROM debian AS start
COPY .env ./
# Change the value of PUBLIC_DOMAIN to 0.0.0.0 if left set to localhost.
RUN sed -i 's/PUBLIC_DOMAIN = localhost/PUBLIC_DOMAIN = 0.0.0.0/g' ./.env
# =======================================
FROM bun AS frontend
# --- Install /frontend.
WORKDIR /frontend
COPY ./frontend ./
COPY --from=start .env ./
RUN bun install --frozen-lockfile --ignore-scripts
RUN bun run build
# --- Install /backend/geometry-computer.
WORKDIR /backend/geometry-computer
COPY ./backend/geometry-computer/package.json ./
COPY ./backend/geometry-computer/bun.lockb ./
RUN bun install --frozen-lockfile
COPY ./backend/geometry-computer ./
# =======================================
FROM rust AS backend
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get install -y build-essential \
cmake \
nasm \
pkg-config \
libclang-dev \
libopenslide-dev \
libssl-dev
COPY --from=start .env ./
WORKDIR /databases
COPY ./databases ./
WORKDIR /backend
COPY ./backend ./
RUN cargo build --release
# =======================================
FROM debian AS final
COPY --from=start .env ./app/.env
COPY --from=frontend /usr/local/bin/bun /usr/local/bin/bun
COPY --from=frontend /usr/local/bin/bunx /usr/local/bin/bunx
COPY --from=backend /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/
# ---
WORKDIR /app/frontend
# Copy node_modules and .svelte-kit from the frontend build.
COPY --from=frontend /frontend/node_modules ./node_modules
COPY --from=frontend /frontend/.svelte-kit ./.svelte-kit
# Copy frontend source files.
COPY ./frontend ./
# ---
WORKDIR /app/backend/geometry-computer
COPY --from=frontend /backend/geometry-computer ./
# ---
WORKDIR /app/databases
COPY --from=backend /databases ./
# ---
WORKDIR /app/backend
COPY --from=backend /backend/target/release/rendering_engine ./
# ---
WORKDIR /app
EXPOSE 3000
EXPOSE 4000
CMD /bin/bash -c "cd backend && ./rendering_engine & cd frontend && bun preview -- --host"