File size: 1,343 Bytes
1f981f8
 
 
 
d690c1e
 
24b9dc9
1f981f8
d690c1e
 
 
 
1f981f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d690c1e
1f981f8
 
d690c1e
1f981f8
 
 
d463342
 
 
1f981f8
 
 
 
 
 
d690c1e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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"]