-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (34 loc) · 1.31 KB
/
Copy pathDockerfile
File metadata and controls
48 lines (34 loc) · 1.31 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
# 1. Build Stage
FROM rust:1.95-slim-bookworm AS builder
WORKDIR /usr/src/app
# Install build dependencies
RUN apt-get update && apt-get install -y pkg-config libssl-dev
# Copy manifests
COPY Cargo.toml Cargo.lock ./
# Create dummy source to cache dependencies
RUN mkdir src && \
echo "fn main() {}" > src/main.rs && \
echo "pub mod lsb {} pub mod capacity {} pub mod chunking {} pub mod buffer_pool {} pub mod mbr {} pub mod db {} pub mod executor {} pub mod server {}" > src/lib.rs && \
cargo build --release && \
rm -rf src
# Copy real source code
COPY src ./src
# Build real application
# Touch main.rs to ensure Cargo detects it as changed
RUN touch src/main.rs && cargo build --release
# 2. Runtime Stage
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the compiled binary from the builder stage
COPY --from=builder /usr/src/app/target/release/subtext /usr/local/bin/subtext
# Create a default directory for the image database
RUN mkdir -p /app/images
# Expose the default HTTP port
EXPOSE 3000
# Set environment variables
ENV SUBTEXT_API_KEY=""
ENV RUST_LOG="info"
# Run the server command targeting the /app/images directory
CMD ["subtext", "serve", "/app/images", "--port", "3000"]