-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
96 lines (72 loc) · 2.92 KB
/
Copy pathDockerfile
File metadata and controls
96 lines (72 loc) · 2.92 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
92
93
94
95
96
# =============================================================================
# Stage 1: Build Frontend (React + Vite)
# =============================================================================
FROM node:26.7.0-alpine AS frontend-builder
WORKDIR /build/frontend
# Copy package files for dependency caching
COPY frontend/react/package*.json ./
RUN npm ci
# Copy frontend source
COPY frontend/react/ ./
# Build production frontend
RUN npm run build
# =============================================================================
# Stage 2: Build Backend (Go)
# =============================================================================
FROM golang:1.26.6-alpine AS backend-builder
WORKDIR /build/backend
# Install build dependencies
RUN apk add --no-cache gcc musl-dev sqlite-dev
# Copy go.mod and go.sum for dependency caching
COPY backend/go/go.mod backend/go/go.sum ./
RUN go mod download
# Copy backend source
COPY backend/go/ ./
# Build static binary with proper CGO flags for Alpine/musl
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
RUN CGO_ENABLED=1 GOOS=linux go build -a -tags musl -ldflags="-s -w -extldflags '-static'" -o /indexarr ./cmd/server
# =============================================================================
# Stage 3: Runtime (Alpine with Nginx + mediainfo + Go backend)
# =============================================================================
FROM alpine:3.24.1
# Build arguments for dynamic user/group configuration
ARG UID=1000
ARG GID=1000
# Install runtime dependencies
RUN apk update && apk upgrade --no-cache && apk add --no-cache \
ca-certificates \
nginx \
mediainfo \
sqlite-libs \
tzdata \
su-exec
# Create necessary directories (user will be created at runtime via entrypoint.sh)
RUN mkdir -p /app/data /app/frontend /var/log/nginx /var/lib/nginx/tmp \
&& mkdir -p /tmp/nginx/{client_body,proxy_temp,fastcgi_temp,uwsgi_temp,scgi_temp}
WORKDIR /app
# Copy backend binary from builder
COPY --from=backend-builder /indexarr /app/indexarr
# Copy frontend build from builder
COPY --from=frontend-builder /build/frontend/dist /app/frontend
# Copy nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
# Copy entrypoint script
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Entrypoint will handle user creation and permission setup at runtime
# Container runs as root initially, entrypoint.sh creates user and switches to it
# Expose ports
EXPOSE 8787
# Set environment variables
ENV SERVER_PORT=8080 \
DB_PATH=/app/data/indexarr.db \
MEDIAINFO_PATH=/usr/bin/mediainfo \
GIN_MODE=release \
MEDIA_LIBRARY_PATHS=/data/movies,/data/series \
MOVIES_LIBRARY_PATHS=/data/movies \
SERIES_LIBRARY_PATHS=/data/series
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD busybox wget --no-verbose --tries=1 -O /dev/null http://localhost:8787/health || exit 1
# Start services
ENTRYPOINT ["/app/entrypoint.sh"]