sonnet / Dockerfile
overwrite69's picture
Update Dockerfile
d463342 verified
FROM node:22-alpine AS builder
WORKDIR /build
# Download latest cursor2api from GitHub as zip (git clone is blocked on HF Spaces)
# To update: Settings → Factory reboot
ARG REPO=7836246/cursor2api
ARG BRANCH=main
RUN wget -qO repo.zip https://github.com/${REPO}/archive/refs/heads/${BRANCH}.zip \
&& unzip -q repo.zip \
&& cp -r cursor2api-${BRANCH}/. . \
&& rm -rf cursor2api-${BRANCH} repo.zip
# Install all deps and build TypeScript
RUN npm ci
RUN npm run build
# ---- Runtime stage ----
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NODE_OPTIONS="--max-old-space-size=4096"
# Install only prod deps
COPY --from=builder /build/package.json /build/package-lock.json ./
RUN npm ci --omit=dev && npm cache clean --force
# Copy built output and static assets
COPY --from=builder --chown=node:node /build/dist ./dist
COPY --from=builder --chown=node:node /build/public ./public
# Copy config example
COPY --from=builder --chown=node:node /build/config.yaml.example ./config.yaml.example
# Entrypoint
COPY --chown=node:node entrypoint.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
# Pre-create writable dirs as root, then hand to node user
RUN mkdir -p /app/logs /app/config \
&& chown -R node:node /app
USER node
# HF Spaces requires port 7860
EXPOSE 7860
ENTRYPOINT ["./entrypoint.sh"]