mirror of
https://github.com/alireza0/s-ui.git
synced 2026-11-17 13:40:41 +00:00
Some checks are pending
Release S-UI / test (push) Waiting to run
Release S-UI / build-frontend (push) Blocked by required conditions
Release S-UI / build-386 (push) Blocked by required conditions
Release S-UI / build-amd64 (push) Blocked by required conditions
Release S-UI / build-armv5 (push) Blocked by required conditions
Release S-UI / build-armv6 (push) Blocked by required conditions
Release S-UI / build-armv7 (push) Blocked by required conditions
Release S-UI / build-arm64 (push) Blocked by required conditions
Release S-UI / build-s390x (push) Blocked by required conditions
Release S-UI / build-windows-amd64 (push) Blocked by required conditions
Release S-UI / build-windows-arm64 (push) Blocked by required conditions
Release S-UI / publish (push) Blocked by required conditions
* Docker: pin libcronet to a cronet-go release and verify its SHA-256 Both Dockerfiles downloaded libcronet.so from the cronet-go releases/latest URL with no verification. Whatever that URL served on build day was copied into the published image and loaded by a root daemon, and the version could drift ahead of the cronet-go module pinned in go.mod -- an unauthenticated, unreproducible input to the image. Pin CRONET_VERSION to v150.0.7871.63-2, the Chromium 150 build that matches the cronet-go module go.mod builds against, record the SHA-256 of each architecture's .so (amd64, 386, arm64, arm -- the four arches the Docker workflow publishes), and fail the build when the download does not match. Verified locally: all four assets from that release pass the same sha256sum -c step the Dockerfile now runs. Prepared by muse ai * Docker: take libcronet from the cronet-go module instead of a pinned download Per review: the github.com/sagernet/cronet-go/lib/linux_<arch> modules already in go.mod ship libcronet.so themselves. Copy it from the module cache after `go mod download`, so the library stays on exactly the go.mod version and is verified through go.sum. Drops the CRONET_* args and the four hand-maintained hashes from both Dockerfiles.
71 lines
2.5 KiB
Docker
71 lines
2.5 KiB
Docker
FROM --platform=$BUILDPLATFORM node:26-alpine AS front-builder
|
|
WORKDIR /app
|
|
COPY frontend/ ./
|
|
RUN npm ci && npm run build
|
|
|
|
FROM golang:1.27-alpine AS backend-builder
|
|
WORKDIR /app
|
|
ARG TARGETARCH
|
|
ARG TARGETVARIANT
|
|
ENV CGO_ENABLED=1
|
|
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
|
|
ENV GOARCH=$TARGETARCH
|
|
|
|
RUN apk upgrade --no-cache --scripts=no apk-tools && \
|
|
apk add --no-cache \
|
|
gcc \
|
|
musl-dev \
|
|
libc-dev \
|
|
make \
|
|
git \
|
|
wget \
|
|
unzip \
|
|
bash \
|
|
curl
|
|
|
|
ENV CC=gcc
|
|
|
|
# Modules in their own layer, so a source-only change keeps them cached.
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# libcronet ships inside the cronet-go lib module pinned in go.mod, so
|
|
# copy it out of the module cache: the library is exactly the go.mod
|
|
# version and go.sum has already verified it. (It used to be fetched
|
|
# from releases/latest with no verification at all.)
|
|
RUN CRONET_DIR=$(go list -m -f '{{.Dir}}' github.com/sagernet/cronet-go/lib/linux_${TARGETARCH}) && \
|
|
cp "$CRONET_DIR/libcronet.so" ./libcronet.so && \
|
|
chmod 755 ./libcronet.so
|
|
|
|
COPY . .
|
|
COPY --from=front-builder /app/dist/ /app/web/html/
|
|
|
|
RUN if [ "$TARGETARCH" = "arm" ]; then export GOARM=7; [ "$TARGETVARIANT" = "v6" ] && export GOARM=6; fi; \
|
|
. ./build-tags.sh && \
|
|
TAGS=$(tags_for docker) && \
|
|
LDFLAGS=$(ldflags_for docker) && \
|
|
go build -ldflags="$LDFLAGS" -tags "$TAGS" -o sui main.go
|
|
|
|
FROM alpine:3
|
|
LABEL org.opencontainers.image.authors="alireza7@gmail.com"
|
|
ENV TZ=Asia/Tehran
|
|
WORKDIR /app
|
|
RUN set -ex && apk upgrade --no-cache --scripts=no apk-tools && \
|
|
apk add --no-cache --upgrade bash ca-certificates nftables su-exec && \
|
|
addgroup -S -g 10001 sui && \
|
|
adduser -S -u 10001 -G sui -h /app -s /sbin/nologin sui
|
|
COPY --from=backend-builder /app/sui /app/libcronet.so /app/
|
|
COPY entrypoint.sh /app/
|
|
|
|
# Asks the binary, which reads the port the operator actually configured. A
|
|
# check with the port written in here goes red the moment they change it in the
|
|
# panel, and an orchestrator then kills a container that was working.
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
|
CMD ["./sui", "healthcheck"]
|
|
|
|
# The container still starts as root by default: a TUN inbound needs
|
|
# CAP_NET_ADMIN in the process's permitted set, and a panel port below 1024
|
|
# needs CAP_NET_BIND_SERVICE. Flipping the default would break both, silently,
|
|
# on every existing deployment. Set SUI_UID (and optionally SUI_GID) to have
|
|
# entrypoint.sh hand over to an unprivileged user instead -- see entrypoint.sh.
|
|
ENTRYPOINT [ "./entrypoint.sh" ]
|