-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
48 lines (31 loc) · 986 Bytes
/
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
FROM node:20.5.1 AS frontend_build
WORKDIR /app
COPY ./frontend/package.json ./
COPY ./frontend/package-lock.json ./
RUN npm install
COPY ./frontend ./
RUN npm run build
FROM docker.io/rust:1-slim-bookworm AS backend_build
ARG pkg=main
WORKDIR /build
COPY ./backend-rust .
RUN --mount=type=cache,target=/build/target \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
set -eux; \
cargo build --release --target-dir /build/target; \
ls; \
objcopy --compress-debug-sections target/release/$pkg ./main
FROM docker.io/debian:bookworm-slim
WORKDIR /app
RUN mkdir data
## copy the main binary
COPY --from=backend_build /build/main ./
RUN mkdir static
COPY --from=frontend_build /app/build/index.html ./static
COPY --from=frontend_build /app/build ./static
## ensure the container listens globally on port 8080
ENV ROCKET_ADDRESS=0.0.0.0
ENV ROCKET_PORT=8080
ENV ROCKET_LOG_LEVEL=NORMAL
CMD ./main