-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.fast
More file actions
79 lines (61 loc) · 2.15 KB
/
Dockerfile.fast
File metadata and controls
79 lines (61 loc) · 2.15 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
# file: Dockerfile.fast
# Ultra-fast Dockerfile using pre-built assets from GitHub Packages
# Build time: ~2-3 minutes instead of 20 minutes
# Use pre-built assets from GitHub Packages
FROM ghcr.io/jdfalk/subtitle-manager/assets:latest AS assets
# Go build stage with minimal dependencies
FROM golang:1.26.0-bookworm AS builder
WORKDIR /src
# Install only essential build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
gcc \
sqlite3 libsqlite3-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy go dependencies first for better caching
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Copy pre-built assets
COPY --from=assets /assets ./webui/dist
# Note: No need to run 'go generate ./webui' since we already have the dist directory
# The embed.go file will automatically embed the dist directory during go build
# Build with optimizations
ARG TARGETOS=linux
ARG TARGETARCH=amd64
RUN CGO_ENABLED=1 \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
go build \
-ldflags="-s -w -X main.version=$(git describe --tags --always)" \
-o subtitle-manager ./
# Final runtime image
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
ca-certificates \
tzdata \
&& rm -rf /var/lib/apt/lists/*
# Explicitly set ffmpeg path so the application can locate it
ENV SM_FFMPEG_PATH=/usr/bin/ffmpeg
# Create non-root user for security
RUN addgroup --system subtitle && adduser --system --ingroup subtitle subtitle
# Create directories with proper ownership
RUN mkdir -p /config /media && \
chown -R subtitle:subtitle /config /media
# Copy binary
COPY --from=builder /src/subtitle-manager /usr/local/bin/subtitle-manager
RUN chmod +x /usr/local/bin/subtitle-manager
COPY docker-init.sh /usr/local/bin/docker-init.sh
RUN chmod +x /usr/local/bin/docker-init.sh
USER subtitle
# Environment variables
ENV SM_CONFIG_FILE=/config/subtitle-manager.yaml \
SM_DB_PATH=/config/db \
SM_DB_BACKEND=pebble \
SM_SQLITE3_FILENAME=subtitle-manager.db \
SM_LOG_LEVEL=info
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/docker-init.sh"]
CMD ["web"]