-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
91 lines (64 loc) · 1.98 KB
/
Dockerfile
File metadata and controls
91 lines (64 loc) · 1.98 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
# Multi-stage Dockerfile for OpenSpec UI
# Stage 1: Node builder - Build frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package*.json ./
# Install dependencies
RUN npm ci
# Copy frontend source
COPY frontend/ ./
# Build frontend
RUN npm run build
# Stage 2: Rust builder - Build backend
FROM rust:1.82-slim AS backend-builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy Cargo files
COPY backend/Cargo.toml backend/Cargo.lock ./backend/
# Create a dummy main.rs to cache dependencies
RUN mkdir -p backend/src && \
echo "fn main() {}" > backend/src/main.rs
# Build dependencies
WORKDIR /app/backend
RUN cargo build --release && \
rm -rf src
# Copy actual backend source
COPY backend/src ./src
# Copy frontend assets for embedding
COPY --from=frontend-builder /app/frontend/dist /app/frontend/dist
# Build backend
RUN touch src/main.rs && \
cargo build --release
# Stage 3: Runtime - Copy artifacts and run
FROM debian:bookworm-slim AS runtime
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m -u 1000 openspec
# Copy backend binary from builder
COPY --from=backend-builder /app/backend/target/release/openspec-ui /app/openspec-ui
# Copy config file
COPY openspec-ui.json /app/openspec-ui.json
# Copy frontend assets from builder
COPY --from=frontend-builder /app/frontend/dist /app/dist
# Set ownership
RUN chown -R openspec:openspec /app
# Switch to non-root user
USER openspec
# Set environment variables
ENV PORT=3000
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
# Run the application
CMD ["/app/openspec-ui"]