-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (35 loc) · 1.36 KB
/
Copy pathDockerfile
File metadata and controls
45 lines (35 loc) · 1.36 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
# syntax=docker/dockerfile:1.7
ARG GO_VERSION=1.24
ARG MIHOMO_IMAGE=metacubex/mihomo:Alpha
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS build
ARG TARGETOS
ARG TARGETARCH
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY *.go index.html lucide.min.js favicon.svg ./
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -buildvcs=false -trimpath -ldflags="-s -w" -o /out/mihomo-sift .
FROM ${MIHOMO_IMAGE} AS mihomo
FROM alpine:3.22
LABEL org.opencontainers.image.title="Mihomo Sift" \
org.opencontainers.image.description="Filter subscription nodes by measured Mihomo latency"
RUN apk add --no-cache ca-certificates tzdata su-exec \
&& addgroup -S -g 10001 probe \
&& adduser -S -D -H -u 10001 -G probe probe \
&& mkdir -p /data \
&& chown probe:probe /data
COPY --from=mihomo /mihomo /usr/local/bin/mihomo
COPY --from=build /out/mihomo-sift /usr/local/bin/mihomo-sift
COPY --chmod=755 docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENV LISTEN_ADDR=:8080 \
DATA_DIR=/data \
MIHOMO_BIN=/usr/local/bin/mihomo
VOLUME ["/data"]
EXPOSE 8080
STOPSIGNAL SIGTERM
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD wget -q -T 2 -O /dev/null http://127.0.0.1:8080/api/health || exit 1
USER root
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["/usr/local/bin/mihomo-sift"]