-
-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathDockerfile
More file actions
105 lines (86 loc) · 3.45 KB
/
Copy pathDockerfile
File metadata and controls
105 lines (86 loc) · 3.45 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
97
98
99
100
101
102
103
104
105
# xx provides cross-compilation toolchains for CGO builds
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
# Stage 1: Build binaries — pinned to BUILDPLATFORM so Go runs natively (fast)
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder
ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFORM
ARG VERSION=0.0.0
ARG CHANNEL=dev
# Copy xx scripts for cross-compilation
COPY --from=xx / /
WORKDIR /app
# Install cross-compilation toolchain via xx
RUN apk add --no-cache clang lld && \
xx-apk add --no-cache gcc g++ musl-dev libc-dev fuse-dev
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download -x
COPY . .
# Build main binary — xx-go sets CC/CXX/GOOS/GOARCH automatically
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=1 \
xx-go build -trimpath \
-ldflags="-w -s -X github.com/sirrobot01/decypharr/pkg/version.Version=${VERSION} -X github.com/sirrobot01/decypharr/pkg/version.Channel=${CHANNEL}" \
-o /decypharr && \
xx-verify /decypharr
# Build healthcheck (no CGO needed, plain cross-compile)
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -trimpath -ldflags="-w -s" \
-o /healthcheck cmd/healthcheck/main.go
# Stage 1.5: Download static ffprobe binary
FROM alpine:latest AS ffprobe-extractor
ARG TARGETARCH
WORKDIR /tmp
RUN apk add --no-cache curl unzip && \
case "$TARGETARCH" in \
amd64) PLATFORM="linux-64" ;; \
arm64) PLATFORM="linux-arm-64" ;; \
*) echo "Unsupported arch: $TARGETARCH" && exit 1 ;; \
esac && \
curl -L "https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v6.1/ffprobe-6.1-${PLATFORM}.zip" -o ffprobe.zip && \
unzip ffprobe.zip && \
chmod +x ffprobe && \
mv ffprobe /ffprobe
# Stage 2: Final image
FROM alpine:latest
ARG VERSION=0.0.0
ARG CHANNEL=dev
LABEL version="${VERSION}-${CHANNEL}"
LABEL org.opencontainers.image.source="https://github.com/sirrobot01/decypharr"
LABEL org.opencontainers.image.title="decypharr"
LABEL org.opencontainers.image.authors="sirrobot01"
LABEL org.opencontainers.image.documentation="https://github.com/sirrobot01/decypharr/blob/main/README.md"
# Install dependencies including rclone (from binary)
RUN apk add --no-cache fuse3 ca-certificates su-exec shadow curl unzip tzdata && \
echo "user_allow_other" >> /etc/fuse.conf && \
case "$(uname -m)" in \
x86_64) ARCH=amd64 ;; \
aarch64) ARCH=arm64 ;; \
armv7l|armv7) ARCH=arm ;; \
*) echo "Unsupported architecture: $(uname -m)" && exit 1 ;; \
esac && \
curl -O "https://downloads.rclone.org/rclone-current-linux-${ARCH}.zip" && \
unzip "rclone-current-linux-${ARCH}.zip" && \
cp rclone-*/rclone /usr/local/bin/ && \
chmod +x /usr/local/bin/rclone && \
rm -rf rclone-* && \
apk del curl unzip
# Copy binaries and entrypoint
COPY --from=builder /decypharr /usr/bin/decypharr
COPY --from=builder /healthcheck /usr/bin/healthcheck
COPY --from=ffprobe-extractor /ffprobe /usr/bin/ffprobe
COPY scripts/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Set environment variables
ENV PUID=1000
ENV PGID=1000
ENV LOG_PATH=/app/logs
EXPOSE 8282
VOLUME ["/app"]
HEALTHCHECK --interval=10s --retries=10 CMD ["/usr/bin/healthcheck", "--config", "/app"]
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/usr/bin/decypharr", "--config", "/app"]