Files
dokril 1ae23d848b
Build and Deploy Gateway / build-and-push (push) Successful in 1m22s
Build and Deploy Gateway / deploy (push) Successful in 16s
Migrate Harbor state and traffic history to SQLite
2026-09-10 19:21:21 +03:00

76 lines
2.9 KiB
Docker

ARG NODE_BUILD_IMAGE=node:24.21.0-bookworm
ARG BASE_IMAGE=debian:bookworm-slim
FROM ${NODE_BUILD_IMAGE} AS build
WORKDIR /src
COPY scripts/check-sqlite-runtime.mjs ./scripts/check-sqlite-runtime.mjs
RUN node scripts/check-sqlite-runtime.mjs
COPY package.json package-lock.json ./
RUN npm ci
COPY index.html vite.config.ts tsconfig*.json ./
COPY src/web ./src/web
COPY src/server ./src/server
COPY src/shared ./src/shared
COPY monitoring/grafana/harbor-gateway.json ./monitoring/grafana/harbor-gateway.json
RUN npm run build:production
FROM ${BASE_IMAGE}
COPY --from=build /usr/local /usr/local
ARG SINGBOX_VERSION=1.14.0-rc.5
ARG INSTALL_RUNTIME_DEPS=true
ARG INSTALL_SINGBOX=true
RUN if [ "${INSTALL_RUNTIME_DEPS}" = "true" ]; then \
apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl iptables iproute2 ieee-data dumb-init \
&& rm -rf /var/lib/apt/lists/*; \
else \
command -v dumb-init >/dev/null \
&& command -v node >/dev/null \
&& command -v iptables >/dev/null; \
fi
RUN if [ "${INSTALL_SINGBOX}" = "true" ]; then \
set -eux; \
arch="$(dpkg --print-architecture)"; \
case "$arch" in \
amd64) sb_arch="amd64" ;; \
arm64) sb_arch="arm64" ;; \
*) echo "Unsupported architecture: $arch" >&2; exit 1 ;; \
esac; \
curl --retry 5 --retry-all-errors --retry-delay 2 -fsSL "https://github.com/SagerNet/sing-box/releases/download/v${SINGBOX_VERSION}/sing-box-${SINGBOX_VERSION}-linux-${sb_arch}.tar.gz" -o /tmp/sing-box.tgz; \
tar -xzf /tmp/sing-box.tgz -C /tmp; \
mv "/tmp/sing-box-${SINGBOX_VERSION}-linux-${sb_arch}/sing-box" /usr/local/bin/sing-box; \
chmod +x /usr/local/bin/sing-box; \
rm -rf /tmp/sing-box*; \
else \
command -v sing-box >/dev/null; \
fi
WORKDIR /app
COPY --from=build /src/dist /app/dist
COPY --from=build /src/node_modules/@bufbuild/protobuf /app/node_modules/@bufbuild/protobuf
COPY --from=build /src/node_modules/@connectrpc/connect /app/node_modules/@connectrpc/connect
COPY --from=build /src/node_modules/@connectrpc/connect-node /app/node_modules/@connectrpc/connect-node
COPY --from=build /src/node_modules/tldts /app/node_modules/tldts
COPY --from=build /src/node_modules/tldts-core /app/node_modules/tldts-core
COPY scripts/check-sqlite-runtime.mjs /app/scripts/check-sqlite-runtime.mjs
RUN node /app/scripts/check-sqlite-runtime.mjs
COPY package.json /app/package.json
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh \
&& mkdir -p /etc/sing-box /var/lib/vpn-proxy /var/lib/sing-box
ENV PORT=3456 \
PROXY_PORT=8080 \
PROXY_BIND_IP=0.0.0.0 \
SING_BOX_API_PORT=19090 \
TPROXY_PORT=7895 \
DATA_DIR=/var/lib/vpn-proxy \
SING_BOX_CONFIG=/etc/sing-box/config.json \
SING_BOX_CACHE=/var/lib/sing-box/cache.db \
SING_BOX_TRAFFIC_SOURCE=snapshot
ENTRYPOINT ["dumb-init", "/entrypoint.sh"]