-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
80 lines (60 loc) · 2.31 KB
/
Dockerfile
File metadata and controls
80 lines (60 loc) · 2.31 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
# Build stage
FROM golang:1.23-alpine AS builder
# Install build dependencies
RUN apk add --no-cache git gcc musl-dev
# Set build arguments
ARG VERSION=dev
ARG COMMIT_SHA=unknown
ARG BUILD_DATE=unknown
# Set working directory
WORKDIR /app
# Copy go module files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build binary with version information
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo \
-ldflags "-s -w \
-X github.com/JohanDevl/Export_Trakt_4_Letterboxd/pkg/version.Version=${VERSION} \
-X github.com/JohanDevl/Export_Trakt_4_Letterboxd/pkg/version.CommitSHA=${COMMIT_SHA} \
-X github.com/JohanDevl/Export_Trakt_4_Letterboxd/pkg/version.BuildDate=${BUILD_DATE}" \
-o export-trakt ./cmd/export_trakt
# Runtime stage
FROM alpine:3.19
# Install CA certificates for HTTPS
RUN apk add --no-cache ca-certificates tzdata
# Create non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Set working directory
WORKDIR /app
# Create directories and set permissions
RUN mkdir -p /app/config /app/logs /app/exports /app/web \
&& chown -R appuser:appgroup /app
# Copy binary from builder stage
COPY --from=builder /app/export-trakt /app/export-trakt
# Copy locales
COPY --from=builder /app/locales /app/locales
# Copy web assets (templates, CSS, JS)
COPY --from=builder /app/web /app/web
# Set environment variables
ENV EXPORT_TRAKT_EXPORT_OUTPUT_DIR=/app/exports
ENV EXPORT_TRAKT_LOGGING_FILE=/app/logs/export.log
# Switch to non-root user
USER appuser
# Create volumes for persistent data
VOLUME ["/app/config", "/app/logs", "/app/exports"]
# Set entrypoint
ENTRYPOINT ["/app/export-trakt"]
# Default command if none is provided
CMD ["--help"]
# Metadata
LABEL org.opencontainers.image.title="Export Trakt for Letterboxd"
LABEL org.opencontainers.image.description="Tool to export Trakt.tv data for Letterboxd import"
LABEL org.opencontainers.image.authors="JohanDevl"
LABEL org.opencontainers.image.url="https://github.com/JohanDevl/Export_Trakt_4_Letterboxd"
LABEL org.opencontainers.image.source="https://github.com/JohanDevl/Export_Trakt_4_Letterboxd"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.created="${BUILD_DATE}"
LABEL org.opencontainers.image.revision="${COMMIT_SHA}"
LABEL org.opencontainers.image.licenses="MIT"