Update docs, Dockerfile, and CI for container registry support

Expanded documentation in both English and Chinese READMEs to include detailed container registry acceleration usage and deployment instructions. Refactored Dockerfile to use a multi-stage build with workerd for self-hosted deployment. Improved .dockerignore for cleaner builds. Updated GitHub Actions workflows to refine path ignores and metadata extraction. Added config.capnp for workerd configuration. Removed obsolete .html file and enhanced CLAUDE.md with comprehensive architecture and development guidance.
This commit is contained in:
xixu-me committed 2025-11-16 17:46:48 +08:00
1 parent 04410291e2
commit ad2bf1933c
9 files changed
+886 -728

No files matched your search

+24 -28
View File
@@ -1,38 +1,34 @@
# Use the official Node.js runtime as the base image
FROM node:20-alpine
# --- Stage 1: build the Worker with Wrangler -----------------------
FROM node:22-alpine AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json first to leverage Docker cache for dependencies
COPY package.json package-lock.json* ./
# Install dependencies & wrangler
COPY package*.json wrangler.toml ./
RUN npm ci
# Install dependencies - use npm ci for reproducible builds if package-lock.json exists, otherwise npm install
RUN if [ -f package-lock.json ]; then npm ci --only=production; else npm install --only=production; fi
# Copy source and build
COPY src ./src
RUN npx wrangler deploy --dry-run --outdir=dist
# Copy the rest of the application code
COPY . .
# --- Stage 2: minimal runtime with workerd -------------------------
FROM node:22-slim AS runtime
# Create a non-root user for security
RUN addgroup -g 1001 -S nodejs && \
adduser -S xget -u 1001
# Install ca-certificates for SSL, then install workerd via npm
RUN apt-get update && \
apt-get install -y ca-certificates && \
rm -rf /var/lib/apt/lists/* && \
npm install -g @cloudflare/workerd-linux-64 && \
ln -s /usr/local/lib/node_modules/@cloudflare/workerd-linux-64/bin/workerd /usr/local/bin/workerd && \
workerd --version
# Change ownership of the app directory to the nodejs user
RUN chown -R xget:nodejs /app
WORKDIR /worker
# Switch to the non-root user
USER xget
# Bring in the compiled Worker bundle and config
COPY --from=builder /app/dist ./dist
COPY config.capnp ./config.capnp
# Expose the port the app runs on
EXPOSE 3000
# Expose the port workerd listens on
EXPOSE 8080
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
# Start the application
CMD ["node", "server.js"]
CMD ["workerd", "serve", "config.capnp"]