-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (60 loc) · 1.71 KB
/
Dockerfile
File metadata and controls
77 lines (60 loc) · 1.71 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
# Multi-stage build for Shoebox
# Stage 1: Build the frontend
FROM node:18-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy frontend package.json and install dependencies
COPY frontend/package.json frontend/package-lock.json* ./
RUN yarn install
# Copy frontend source code
COPY frontend/ ./
# Build the frontend
RUN yarn run build
# Stage 2: Build the Rust backend
FROM rust:bookworm AS backend-builder
WORKDIR /app
# Install dependencies for building
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
libsqlite3-dev \
libavformat-dev \
libavcodec-dev \
libavutil-dev \
libavfilter-dev \
libswscale-dev \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Copy Cargo.toml and Cargo.lock
COPY Cargo.toml Cargo.lock ./
# Copy actual source code
COPY src/ src/
COPY migrations/ migrations/
# Build the application
RUN cargo build --release
# Stage 3: Create the final image
FROM debian:bookworm-slim
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libsqlite3-0 \
ffmpeg \
ca-certificates \
exiftool \
&& rm -rf /var/lib/apt/lists/*
# Copy the built frontend from stage 1
COPY --from=frontend-builder /app/frontend/dist /app/frontend/dist
# Copy the built backend from stage 2
COPY --from=backend-builder /app/target/release/shoebox /app/shoebox
# Create directories for data
RUN mkdir -p /app/data /app/thumbnails /app/exports
# Set environment variables
ENV SERVER_HOST=0.0.0.0
ENV SERVER_PORT=3000
#ENV DATABASE_URL=sqlite:/app/data/videos.db
ENV THUMBNAIL_PATH=/app/thumbnails
ENV EXPORT_BASE_PATH=/app/exports
ENV FRONTEND_PATH=/app/frontend/dist
# Expose the port
EXPOSE 3000
# Run the application
CMD ["/app/shoebox"]