-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (39 loc) · 1.22 KB
/
Dockerfile
File metadata and controls
54 lines (39 loc) · 1.22 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
# Multi-stage Dockerfile for opencode-share application
# Stage 1: Builder
FROM rust:latest as builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy Cargo files
COPY Cargo.toml Cargo.lock ./
# Create dummy main.rs to cache dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs
# Build dependencies (this layer is cached unless Cargo.toml changes)
RUN cargo build --release && rm -rf src
# Copy source code
COPY src ./src/
COPY migrations ./migrations/
COPY static ./static/
COPY templates ./templates/
# Build the application
RUN touch src/main.rs && cargo build --release
# Stage 2: Runtime
FROM debian:bookworm-slim
# Set working directory
WORKDIR /app
# Copy the binary from builder stage
COPY --from=builder /app/target/release/opencode-share ./opencode-share
# Copy migrations and static files
COPY --from=builder /app/migrations ./migrations/
COPY --from=builder /app/static ./static/
COPY --from=builder /app/templates ./templates/
# Expose port
EXPOSE 3006
# Set environment variables
ENV RUST_LOG=opencode_share=info,tower_http=info
# Run the application
CMD ["./opencode-share"]