-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.server
More file actions
61 lines (50 loc) · 1.91 KB
/
Dockerfile.server
File metadata and controls
61 lines (50 loc) · 1.91 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
ARG API_ENDPOINT_SERVER=https://rosta.fsektionen.se
ARG API_ENDPOINT_TRUSTAUTH=https://rosta.trustauth.fsektionen.se
ARG API_ENDPOINT_SERVER_TO_TRUSTAUTH=https://rustsystem-trustauth:2444
ARG DEV=false
# NOTE: SALT_HEX is different from the value in .env. This value is not secret, only used to maintain uniqueness. It's purposefully different from the development value in order to maintain uniqueness in production.
ARG SALT_HEX=fa592f8bf54e9e6710f9e63699651c9d
ARG KEYGEN_ITERATIONS=200000
FROM node:24-bullseye AS frontend-builder
RUN npm install -g pnpm
WORKDIR /app/frontend
COPY frontend/package.json frontend/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY frontend/ .
ARG API_ENDPOINT_SERVER
ARG API_ENDPOINT_TRUSTAUTH
ARG DEV
ARG SALT_HEX
ARG KEYGEN_ITERATIONS
RUN --mount=type=bind,source=.git,target=/app/frontend/.git pnpm run build
RUN ls
FROM rust:1.91-bullseye AS backend-builder
WORKDIR /app
COPY Cargo.server.toml ./Cargo.toml
COPY Cargo.lock ./
COPY rustsystem-server/ ./rustsystem-server/
COPY rustsystem-core/ ./rustsystem-core/
ARG API_ENDPOINT_SERVER
ARG API_ENDPOINT_SERVER_TO_TRUSTAUTH
ARG SALT_HEX
ARG KEYGEN_ITERATIONS
# Now overwrite stubs with real certs and recompile only the crates that embed them.
COPY mtls-prod/ca/ ./mtls/ca/
COPY mtls-prod/server/ ./mtls/server/
RUN touch rustsystem-server/src/main.rs rustsystem-server/src/lib.rs
RUN cargo build --release --bin rustsystem-server
FROM debian:bullseye-slim AS runtime
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the built backend binary
COPY --from=backend-builder /app/target/release/rustsystem-server ./rustsystem-server
# Copy the built frontend
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
# Create a non-root user
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
EXPOSE 1443
EXPOSE 1444
CMD ["./rustsystem-server"]