1+ FROM alpine AS cloner
2+ ARG VERSION
3+ RUN apk add --update --no-cache tmux ttyd git && \
4+ git clone -b $VERSION https://github.com/sirrobot01/decypharr.git /source
5+
6+ # Stage 1: Build binaries
7+ FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder
8+
9+ ARG TARGETOS
10+ ARG TARGETARCH
11+ ARG VERSION=0.0.0
12+ ARG CHANNEL=dev
13+
14+ WORKDIR /app
15+
16+ COPY --from=cloner /source/go.mod /source/go.sum ./
17+ RUN --mount=type=cache,target=/go/pkg/mod \
18+ go mod download -x
19+
20+ COPY --from=cloner /source/. .
21+
22+ # Build main binary
23+ RUN --mount=type=cache,target=/go/pkg/mod \
24+ --mount=type=cache,target=/root/.cache/go-build \
25+ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
26+ go build -trimpath \
27+ -ldflags="-w -s -X github.com/sirrobot01/decypharr/pkg/version.Version=${VERSION} -X github.com/sirrobot01/decypharr/pkg/version.Channel=${CHANNEL}" \
28+ -o /decypharr
29+
30+ # Build healthcheck (optimized)
31+ RUN --mount=type=cache,target=/go/pkg/mod \
32+ --mount=type=cache,target=/root/.cache/go-build \
33+ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
34+ go build -trimpath -ldflags="-w -s" \
35+ -o /healthcheck cmd/healthcheck/main.go
36+
37+ # Stage 2: Create directory structure
38+ FROM alpine:3.19 as dirsetup
39+ RUN mkdir -p /app/logs && \
40+ mkdir -p /app/cache && \
41+ chmod 777 /app/logs && \
42+ touch /app/logs/decypharr.log && \
43+ chmod 666 /app/logs/decypharr.log
44+
45+ # Stage 3: Final image
46+ FROM ghcr.io/ipromknight/alpine:rolling
47+
48+ LABEL version = "${VERSION}-${CHANNEL}"
49+ LABEL org.opencontainers.image.source = "https://github.com/sirrobot01/decypharr"
50+ LABEL org.opencontainers.image.title = "decypharr"
51+ LABEL org.opencontainers.image.authors = "sirrobot01"
52+ LABEL org.opencontainers.image.documentation = "https://github.com/sirrobot01/decypharr/blob/main/README.md"
53+
54+ # Copy binaries
55+ COPY --from=builder --chown=568:568 /decypharr /usr/bin/decypharr
56+ COPY --from=builder --chown=568:568 /healthcheck /usr/bin/healthcheck
57+
58+ # Copy pre-made directory structure
59+ COPY --from=dirsetup --chown=568:568 /app /app
60+
61+ # Metadata
62+ ENV LOG_PATH=/config/logs
63+ EXPOSE 8282
64+
65+ USER 568
66+
67+ # So that the app will start for goss tests
68+ COPY --chown=568:568 apps/decypharr/config.json /config/
69+
70+ COPY --chmod=0755 apps/decypharr/promknight-entrypoint.sh /promknight-entrypoint.sh
0 commit comments