-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathDockerfile
33 lines (25 loc) · 1.1 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
FROM --platform=${BUILDPLATFORM} golang:1.20.13-alpine AS go
WORKDIR /app
ARG BUILDOS BUILDARCH TARGETOS TARGETARCH GITHUB_REF PROGRAM_NIGHTLY
ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=7
RUN PROGRAM_VERSION="$(basename ${GITHUB_REF})"; \
if [ "${GOARCH}" == 'arm' ]; then \
PROGRAM_VERSION="${PROGRAM_VERSION} (${TARGETOS}, ${TARGETARCH}v7)"; \
else \
PROGRAM_VERSION="${PROGRAM_VERSION} (${TARGETOS}, ${TARGETARCH})"; \
fi; \
if [ "${PROGRAM_NIGHTLY}" == 'true' ]; then \
PROGRAM_VERSION="${PROGRAM_VERSION} (Nightly)"; \
fi; \
echo "export PROGRAM_VERSION='${PROGRAM_VERSION}'" > /envfile
RUN . /envfile; echo "Running on ${BUILDOS}/${BUILDARCH}, Building for ${TARGETOS}/${TARGETARCH}, Version: ${PROGRAM_VERSION}"
ADD lang/ *LICENSE* *.md *.go *.sh *.txt *.json go.mod go.sum ./
RUN go mod download
RUN . /envfile; go build -ldflags "-w -X \"main.programVersion=${PROGRAM_VERSION}\"" -o qBittorrent-ClientBlocker
RUN rm -f *.go go.mod go.sum
FROM alpine
WORKDIR /app
COPY --from=go /app ./
RUN chmod +x ./entrypoint.sh
RUN apk update && apk add --no-cache jq socat
ENTRYPOINT ["/app/entrypoint.sh"]