mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-04 16:34:52 +03:00
15feed9ea7
The OSS Scanner image pointed XRAY_E2E_BINARY at the release binary that DockerInit.sh downloads, while CI's `make xray-e2e` builds the core from the commit go.mod pins. The two are the same commit today (v26.11.9), but they part whenever go.mod moves to an unreleased commit, and the scanner's baseline would then run the gRPC tests against a core the panel code was not written for. The image now builds that core as xray-e2e and points the variable at it; the release binary stays as /usr/local/bin/xray, which is what a live panel runs. The comment also named two of the three packages the variable turns on.
65 lines
2.8 KiB
Docker
65 lines
2.8 KiB
Docker
# Build environment for Anthropic's OSS Scanner (https://github.com/anthropics/oss-scanner).
|
|
# The scanner builds this with the repository as the context, then audits the image offline:
|
|
# everything the build, the tests and a reproducer need must be fetched here.
|
|
|
|
FROM node:26-trixie-slim AS node
|
|
|
|
FROM golang:1.27.4-trixie
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive \
|
|
CGO_ENABLED=1 \
|
|
CGO_CFLAGS="-D_LARGEFILE64_SOURCE" \
|
|
GOTOOLCHAIN=local
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential ca-certificates curl git jq procps sqlite3 unzip \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Node 26 is required: `make gen` imports .ts files directly and needs its type stripping.
|
|
COPY --from=node /usr/local/bin/node /usr/local/bin/node
|
|
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
|
|
RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
|
|
&& ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \
|
|
&& node --version && npm --version
|
|
|
|
# scanner contract: the checkout lives inside the image, at /src
|
|
COPY . /src
|
|
WORKDIR /src
|
|
|
|
RUN go mod download && go mod verify
|
|
|
|
# The Go binary embeds the Vite build from internal/web/dist, so the frontend goes first.
|
|
# HUSKY=0 skips the git-hook install, which needs a .git directory the build context may lack.
|
|
RUN cd frontend && HUSKY=0 npm ci && npm run build
|
|
|
|
# Debug info and no inlining, so stack traces and debuggers map straight to the source.
|
|
RUN go build -gcflags=all="-N -l" -o /usr/local/bin/x-ui . \
|
|
&& ln -s /usr/local/bin/x-ui /src/x-ui
|
|
|
|
# Xray-core, the mtg-multi MTProto sidecar and the geo databases, exactly as the release image ships them.
|
|
RUN ./DockerInit.sh "$(dpkg --print-architecture)" \
|
|
&& ln -s "/src/build/bin/xray-linux-$(dpkg --print-architecture)" /usr/local/bin/xray \
|
|
&& xray version
|
|
|
|
# The real-core tests get the core go.mod pins, built as `make xray-e2e` builds it in CI:
|
|
# the release binary above lags whenever go.mod moves to an unreleased commit.
|
|
RUN go build -o /usr/local/bin/xray-e2e github.com/xtls/xray-core/main \
|
|
&& xray-e2e version
|
|
|
|
# Turns on every test gated on XRAY_E2E_BINARY (internal/xray, internal/amneziawgnet, internal/web/service).
|
|
ENV XRAY_E2E_BINARY=/usr/local/bin/xray-e2e
|
|
|
|
# Baseline tests: also warms the build cache. A failure is logged, never fatal.
|
|
RUN go test -count=1 -timeout 30m ./... > /src/.oss-scanner-go-test.log 2>&1 \
|
|
|| echo "WARNING: go test reported failures, see /src/.oss-scanner-go-test.log"
|
|
RUN cd frontend && npx vitest run --project unit --project components > /src/.oss-scanner-vitest.log 2>&1 \
|
|
|| echo "WARNING: vitest reported failures, see /src/.oss-scanner-vitest.log"
|
|
|
|
# Reproducers and patches must build with the network gone.
|
|
ENV GOPROXY=off \
|
|
GOSUMDB=off \
|
|
GOFLAGS=-mod=readonly \
|
|
npm_config_offline=true
|
|
|
|
CMD ["bash"]
|