forked from varbhat/exatorrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
73 lines (51 loc) · 1.72 KB
/
Dockerfile
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
# syntax=docker/dockerfile:1
FROM docker.io/alpine:3.18 as base
# Build the web ui from source
FROM --platform=$BUILDPLATFORM docker.io/node:18 AS build-node
WORKDIR /exa
ADD internal/web /exa/internal/web
ADD Makefile /exa/
RUN make web
# Build the application from source
FROM docker.io/golang:1.22-bookworm AS build-go
ARG TARGETOS TARGETARCH
WORKDIR /exa
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
COPY --link --from=build-node /exa/internal/web/build /exa/internal/web/build
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make app
# Artifact Target
FROM scratch as artifact
ARG TARGETOS TARGETARCH TARGETVARIANT
COPY --link --from=build-go /exa/build/exatorrent /exatorrent-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}
# Failover if contexts=artifacts=<path> is not set
FROM scratch AS artifacts
# Releaser flat all artifacts
FROM base AS releaser
WORKDIR /out
RUN --mount=from=artifacts,source=.,target=/artifacts <<EOT
set -e
cp /artifacts/**/* /out/ 2>/dev/null || cp /artifacts/* /out/
EOT
FROM scratch AS release
COPY --link --from=releaser /out /
# Final stage
# Deploy the application binary into a lean image
FROM base
LABEL maintainer="varbhat"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.name="varbhat/exatorrent"
LABEL org.label-schema.description="self-hostable torrent client"
LABEL org.label-schema.url="https://github.com/varbhat/exatorrent"
LABEL org.label-schema.vcs-url="https://github.com/varbhat/exatorrent"
COPY --link --from=build-go --chown=1000:1000 /exa/build/exatorrent /exatorrent
RUN apk add -U --upgrade --no-cache \
ca-certificates
USER 1000:1000
WORKDIR /exa
RUN mkdir -p exadir
EXPOSE 5000 42069
VOLUME /exa/exadir
ENTRYPOINT ["/exatorrent"]
CMD ["-dir", "exadir"]