-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.prod
84 lines (61 loc) · 2.23 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
FROM oven/bun:1.1.33 AS bun
FROM rust:1.80.0-slim-bookworm AS rust
FROM debian:bookworm-slim AS debian
# =======================================
FROM bun AS frontend
# Install frontend.
WORKDIR /frontend
COPY ./frontend ./
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
RUN bun install --frozen-lockfile --ignore-scripts
RUN bun run build
# Install geometry-computer.
WORKDIR /backend
COPY ./backend/geometry-computer/package.json ./
COPY ./backend/geometry-computer/bun.lockb ./
RUN bun install --frozen-lockfile
# =======================================
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 .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
WORKDIR /backend
COPY ./backend ./
RUN cargo build --release
# =======================================
FROM debian AS final
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/
COPY --from=backend .env ./app/.env
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/node_modules ./
COPY ./backend/geometry-computer ./
WORKDIR /app/backend
COPY --from=backend /backend/target/release/rendering_engine ./
RUN mkdir -p ./state
WORKDIR /app
RUN mkdir -p ./stores
# TODO: This should be handled by the app.
RUN mkdir -p ./stores/Local Storage
RUN mkdir -p ./stores/Bin
EXPOSE 4000
EXPOSE 3000
CMD /bin/bash -c "cd backend && ./rendering_engine & cd frontend && bun preview -- --host"