-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (52 loc) · 1.89 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (52 loc) · 1.89 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
# ---- Stage 1: Build the SvelteKit dashboard ----
FROM node:20-alpine AS ui-builder
WORKDIR /ui
COPY dashboard-ui/package*.json ./
RUN npm ci
COPY dashboard-ui/ ./
RUN npm run build
# ---- Stage 2: Build the Rust binary ----
FROM rust:1-bookworm AS rust-builder
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Cache dependency compilation separately from application code
COPY Cargo.toml Cargo.lock ./
COPY migrations/ ./migrations/
RUN mkdir -p src && echo 'fn main() {}' > src/main.rs \
&& cargo build --release \
&& rm -f target/release/deps/tus_server*
COPY src/ ./src/
RUN touch src/main.rs && cargo build --release
# ---- Stage 3: Minimal runtime image ----
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
libssl3 \
ca-certificates \
curl \
gosu \
# ClamAV — provides clamscan and freshclam for the AV processor.
# Signatures (~270 MB) are downloaded at runtime into a mounted volume,
# so they are NOT baked into this image.
clamav \
&& rm -rf /var/lib/apt/lists/* \
# Remove the default freshclam.conf so we can pass --datadir freely.
&& rm -f /etc/clamav/freshclam.conf \
# Create non-root service account.
&& useradd -r -u 1000 -s /sbin/nologin -c "Tuskar service" tuskar
WORKDIR /app
COPY --from=rust-builder /app/target/release/tus-server ./
COPY --from=ui-builder /ui/build ./dashboard-ui/build/
COPY docker-entrypoint.sh ./
VOLUME ["/data", "/uploads"]
ENV DATABASE_URL=/data/tus.db
ENV STORAGE_DIR=/uploads
ENV BASE_URL=http://localhost:3000
ENV BIND_ADDR=0.0.0.0:3000
ENV RUST_LOG=info
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -fs http://localhost:3000/api/health || exit 1
ENTRYPOINT ["./docker-entrypoint.sh"]