forked from isLinXu/crablet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
91 lines (71 loc) · 2.34 KB
/
Copy pathDockerfile
File metadata and controls
91 lines (71 loc) · 2.34 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
90
91
# syntax=docker/dockerfile:1
# Stage 1: Builder
FROM rust:1.80-slim-bookworm as builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy manifests first to cache dependencies
COPY Cargo.toml Cargo.lock ./
COPY crablet/Cargo.toml crablet/
# Create dummy source to build dependencies
RUN mkdir -p crablet/src && \
echo "fn main() {println!(\"dummy\")}" > crablet/src/main.rs && \
cargo build --release --package crablet
# Remove dummy source
RUN rm -rf crablet/src
# Copy actual source code
COPY . .
# Build the actual application
# Need to touch main.rs to force rebuild of the binary (dependencies are cached)
RUN touch crablet/src/main.rs && \
cargo build --release --package crablet
# Stage 2: Runtime
FROM debian:bookworm-slim
# Install runtime dependencies
# - ca-certificates: HTTPS
# - openssl: TLS
# - ffmpeg: Audio processing (Whisper/TTS)
# - sqlite3: DB debugging
# - curl: Healthchecks
RUN apt-get update && apt-get install -y \
ca-certificates \
openssl \
ffmpeg \
sqlite3 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -ms /bin/bash crablet
WORKDIR /app
# Copy binary from builder
COPY --from=builder /app/target/release/crablet /usr/local/bin/crablet
# Create directory structure
RUN mkdir -p /app/skills /app/data /app/config /app/assets /app/templates
RUN chown -R crablet:crablet /app
# Copy static assets and templates if they exist in source
COPY --from=builder /app/crablet/templates /app/templates
# COPY --from=builder /app/crablet/assets /app/assets
# Switch to user
# Note: For Docker socket access, we might need to run as root or add user to docker group dynamically.
# For simplicity in this template, we default to root to ensure docker socket access works out of the box,
# but in production, one should use group mapping.
# USER crablet
# Set environment variables
ENV RUST_LOG=info
ENV XDG_CONFIG_HOME=/app/config
ENV XDG_DATA_HOME=/app/data
ENV CRABLET_HOST=0.0.0.0
# Expose ports
# 3000: Web UI
# 18789: Gateway RPC
EXPOSE 3000 18789
# Healthcheck
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:18789/ || exit 1
# Default command
CMD ["crablet", "serve-web", "--port", "3000"]