This repository was archived by the owner on Feb 11, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
89 lines (70 loc) · 2.13 KB
/
Dockerfile
File metadata and controls
89 lines (70 loc) · 2.13 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
# === Generate Tailwindcss ===
FROM oven/bun:1.3-alpine AS bun_stage
WORKDIR /app
# Build Dependencies
COPY package.json bun.lock ./
RUN bun i
# Generate CSS
COPY tailwind.css ./
COPY src ./src
RUN bunx @tailwindcss/cli -i ./tailwind.css -o ./assets/tailwind.css --minify
# === Compile Rust App ===
# Use debian bookworm-slim as DX CLI is not compiled for alpine
FROM rust:1.90-slim AS rust_stage
WORKDIR /app
# Build Dependencies
# - `pkg-config` required for `cargo build`
# - `libssl-dev` required for `cargo build`
# - `curl` required for `utoipa` crate for swagger API docs
# - `unzip` required for installing dioxus CLI
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
curl \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Install wasm32-unknown-unknown
RUN rustup default stable \
&& rustup target add wasm32-unknown-unknown
# Install Dioxus CLI
RUN mkdir -p /root/.cargo/bin \
&& curl -sSL https://dioxus.dev/install.sh | bash
ENV PATH="/root/.cargo/bin:${PATH}"
# Copy dependency manifests
COPY Cargo.toml Cargo.lock ./
COPY .cargo ./.cargo
COPY entity ./entity
COPY migration ./migration
COPY test-utils ./test-utils
# Build Rust application
COPY assets ./assets
COPY src ./src
COPY --from=bun_stage /app/assets/tailwind.css /app/assets/tailwind.css
# Cache compiled depdencies for future builds
RUN --mount=type=cache,target=/app/target \
--mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/root/.cargo/git \
dx build --release \
&& mkdir -p /app/output \
&& cp -r /app/target/dx/timerboard/release/web /app/output/
# === Run application ===
FROM debian:bookworm-slim
ARG APP_NAME=timerboard
ARG IP=0.0.0.0
ARG PORT=8080
ENV APP_NAME=${APP_NAME}
ENV IP=${IP}
ENV PORT=${PORT}
WORKDIR /app
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -m -u 1000 ${APP_NAME} \
&& mkdir -p /app/data \
&& chown -R ${APP_NAME}:${APP_NAME} /app
COPY --from=rust_stage --chown=${APP_NAME}:${APP_NAME} \
/app/output/web/ /app
USER ${APP_NAME}
EXPOSE ${PORT}
CMD ["sh", "-c", "./${APP_NAME}"]