FROM golang:1.26-alpine AS cliproxy-builder ARG CLIPROXYAPI_REF=latest ARG CLIPROXYAPI_VERSION= ARG CLIPROXYAPI_COMMIT= ARG CLIPROXYAPI_BUILD_DATE= COPY patches/apply_xai_fail_closed.go /tmp/apply_xai_fail_closed.go COPY patches/xai_fail_closed.go /tmp/xai_fail_closed.go COPY patches/xai_fail_closed_test.go /tmp/xai_fail_closed_test.go RUN set -eu; \ unset HTTP_PROXY HTTPS_PROXY ALL_PROXY http_proxy https_proxy all_proxy; \ if [ "$CLIPROXYAPI_REF" = "latest" ]; then \ latest_json="$(wget -qO- https://api.github.com/repos/router-for-me/CLIProxyAPI/releases/latest)"; \ resolved_ref="$(printf '%s' "$latest_json" | sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)"; \ resolved_build_date="$(printf '%s' "$latest_json" | sed -n 's/.*"published_at"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)"; \ [ -n "$resolved_ref" ]; \ tar_url="https://github.com/router-for-me/CLIProxyAPI/archive/refs/tags/${resolved_ref}.tar.gz"; \ else \ resolved_ref="$CLIPROXYAPI_REF"; \ resolved_build_date="unknown"; \ case "$resolved_ref" in \ v*) tar_url="https://github.com/router-for-me/CLIProxyAPI/archive/refs/tags/${resolved_ref}.tar.gz" ;; \ *) tar_url="https://github.com/router-for-me/CLIProxyAPI/archive/refs/heads/${resolved_ref}.tar.gz" ;; \ esac; \ fi; \ version="${CLIPROXYAPI_VERSION:-$resolved_ref}"; \ commit="${CLIPROXYAPI_COMMIT:-$resolved_ref}"; \ build_date="${CLIPROXYAPI_BUILD_DATE:-$resolved_build_date}"; \ mkdir -p /src/CLIProxyAPI; \ wget -qO /tmp/cliproxy.tar.gz "$tar_url"; \ tar -xzf /tmp/cliproxy.tar.gz -C /src/CLIProxyAPI --strip-components=1; \ cd /src/CLIProxyAPI; \ cp /tmp/xai_fail_closed.go sdk/cliproxy/auth/xai_fail_closed.go; \ cp /tmp/xai_fail_closed_test.go sdk/cliproxy/auth/xai_fail_closed_test.go; \ go run /tmp/apply_xai_fail_closed.go -- sdk/cliproxy/auth/conductor_lifecycle.go; \ gofmt -w sdk/cliproxy/auth/xai_fail_closed.go sdk/cliproxy/auth/xai_fail_closed_test.go sdk/cliproxy/auth/conductor_lifecycle.go; \ go test ./sdk/cliproxy/auth -run '^TestApplyXAIFailClosedProxy$' -count=1; \ CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X 'main.Version=${version}' -X 'main.Commit=${commit}' -X 'main.BuildDate=${build_date}'" -o /tmp/CLIProxyAPI ./cmd/server/ FROM curlimages/curl:8.12.1 AS curlbin FROM minio/mc:latest AS mcbin FROM python:3.12-alpine AS hfpy RUN unset HTTP_PROXY HTTPS_PROXY ALL_PROXY http_proxy https_proxy all_proxy && \ pip install --no-cache-dir 'huggingface_hub==1.4.1' FROM ghcr.io/sagernet/sing-box:v1.12.12 AS singboxbin FROM eceasy/cli-proxy-api:latest # Keep behavior from upstream image but run under neutral paths/names. WORKDIR /opt/daili COPY --from=curlbin /usr/bin/curl /usr/bin/curl COPY --from=curlbin /usr/lib/ /usr/lib/ COPY --from=curlbin /lib/ /lib/ COPY --from=mcbin /usr/bin/mc /usr/bin/mc COPY --from=hfpy /usr/local/ /usr/local/ COPY --from=singboxbin /usr/local/bin/sing-box /usr/local/bin/sing-box COPY --from=cliproxy-builder /tmp/CLIProxyAPI /usr/local/bin/daili-gateway RUN chmod +x /usr/local/bin/daili-gateway ENV WRITABLE_PATH=/tmp ENV USAGE_AUTOSAVE_INTERVAL=300 COPY entrypoint.sh /opt/daili/entrypoint.sh COPY hf_snapshot.py /opt/daili/hf_snapshot.py COPY model_price_bootstrap.py /opt/daili/model_price_bootstrap.py COPY objectstore_sync.py /opt/daili/objectstore_sync.py COPY cleanup_invalid_auths.py /opt/daili/cleanup_invalid_auths.py COPY codex_ws_auths.py /opt/daili/codex_ws_auths.py COPY ss_bridge.py /opt/daili/ss_bridge.py COPY xai_auth_proxy.py /opt/daili/xai_auth_proxy.py RUN chmod +x /opt/daili/entrypoint.sh EXPOSE 8317 CMD ["/opt/daili/entrypoint.sh"]