skillhub/web/Dockerfile
FenjuFu e1e6f092f7
fix(deps): pin patched nginx runtime (#1105)
* fix(deps): pin nginx runtime to 1.31.9

Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>

* fix(deps): pin patched nginx runtime

Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>

* fix(deploy): use curl for Debian nginx compose health checks

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

---------

Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
Co-authored-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-11-19 21:24:25 +08:00

39 lines
2.1 KiB
Docker

# The frontend output is static and architecture-neutral. Build it on the
# Buildx host so linux/riscv64 does not depend on a target-architecture Node.js
# image; only the multi-architecture Nginx runtime is target-specific.
FROM --platform=$BUILDPLATFORM node:22-alpine AS build
RUN corepack enable
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
COPY patches ./patches
# Corepack uses Node fetch; explicitly honor the build proxy for its download.
RUN NODE_USE_ENV_PROXY=1 pnpm install --frozen-lockfile
COPY . .
ARG VITE_BASE_PATH=/__SKILLHUB_WEB_BASE_PATH__/
ENV VITE_BASE_PATH=$VITE_BASE_PATH
RUN pnpm build
# The patched Debian stable image is also published for linux/riscv64.
# Verify registry manifests: the new Alpine tags can lag the source tag list.
FROM nginx:1.30.7-trixie
ENV SKILLHUB_TRUST_FORWARDED_PROTO=false
ENV NGINX_ENTRYPOINT_LOCAL_RESOLVERS=1
# Record a fixed build-time base so the entrypoint defaults SKILLHUB_WEB_BASE_PATH
# to it and generates matching Nginx routing without repeating the value at runtime.
# Placeholder builds (the default) intentionally write no file and default to '/'.
ARG VITE_BASE_PATH=/__SKILLHUB_WEB_BASE_PATH__/
RUN if [ "$VITE_BASE_PATH" != "/__SKILLHUB_WEB_BASE_PATH__/" ]; then \
mkdir -p /etc/skillhub && printf '%s' "$VITE_BASE_PATH" > /etc/skillhub/baked-base-path; \
fi
COPY --from=build /app/dist /usr/share/nginx/html
COPY --from=build /app/src/docs/skill.md.template /usr/share/nginx/html/registry/skill.md.template
COPY nginx.conf.template /etc/nginx/templates/default.conf.template
COPY runtime-config.js.template /usr/share/nginx/html/runtime-config.js.template
COPY docker-entrypoint.d/20-base-path.sh /docker-entrypoint.d/20-base-path.sh
COPY docker-entrypoint.d/30-runtime-config.sh /docker-entrypoint.d/30-runtime-config.sh
COPY analytics-config.awk /etc/skillhub/analytics-config.awk
COPY docker-entrypoint.d/40-analytics.sh /docker-entrypoint.d/40-analytics.sh
RUN chmod +x /docker-entrypoint.d/20-base-path.sh /docker-entrypoint.d/30-runtime-config.sh /docker-entrypoint.d/40-analytics.sh
EXPOSE 80
HEALTHCHECK --interval=10s --timeout=3s \
CMD curl -fsS http://127.0.0.1/nginx-health || exit 1