forked from Txio-labs/txio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (41 loc) · 1.66 KB
/
Copy pathDockerfile
File metadata and controls
59 lines (41 loc) · 1.66 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
# Build stage
FROM rust:1.88.0-slim-bookworm AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the full Rust workspace so Cargo can resolve all workspace members.
# This avoids missing-path issues when workspace members have deeper path dependencies.
COPY Cargo.toml Cargo.lock ./
COPY backend ./backend
COPY cli ./cli
# Build both backend and cli from the workspace root.
RUN cargo build --release --package txio-api --package txio
# Runtime stage
FROM debian:bookworm-slim
# Add a non-root system user so the process never runs as root.
RUN useradd --system --uid 10001 txio
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates libssl3 && rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m -u 10001 appuser
# Copy backend binary
COPY --from=builder /app/target/release/txio-api /app/api
# Copy CLI binary to system PATH so TerminalService can find it
COPY --from=builder /app/target/release/txio /usr/local/bin/txio
# Create a dedicated non-root user and grant it access to runtime paths.
# Using a numeric UID avoids relying on /etc/passwd inside the minimal image.
RUN install -d -o 10001 -g 10001 /app/temp
# Transfer ownership to the non-root user before switching to it.
RUN chown -R txio:txio /app
USER 10001:10001
# Set directory ownership
RUN chown -R appuser:appuser /app
# Set environment variables
ENV RUST_LOG=info
ENV MONGO_URI=mongodb://mongodb:27017/txio
EXPOSE 8000
# Run as non-root user
USER appuser
# The entrypoint is the backend API
CMD ["./api"]