| FROM node:20-slim AS deps |
|
|
| WORKDIR /app |
|
|
| RUN apt-get update && apt-get install -y \ |
| python3 make g++ git \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| COPY package*.json ./ |
|
|
| RUN npm ci --legacy-peer-deps |
|
|
| RUN cd node_modules/node-pty && PYTHON=$(which python3) npx node-gyp rebuild |
|
|
| FROM node:20-slim AS builder |
|
|
| WORKDIR /app |
|
|
| COPY --from=deps /app/node_modules ./node_modules |
| COPY . . |
|
|
| RUN npm run build:client |
|
|
| FROM node:20-slim AS runner |
|
|
| RUN apt-get update && apt-get install -y \ |
| curl tini procps fish \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| RUN ARCH=$(dpkg --print-architecture) && \ |
| if [ "$ARCH" = "amd64" ]; then CF_ARCH="amd64"; \ |
| elif [ "$ARCH" = "arm64" ]; then CF_ARCH="arm64"; \ |
| else CF_ARCH="amd64"; fi && \ |
| curl -fsSL "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${CF_ARCH}.deb" -o /tmp/cloudflared.deb && \ |
| dpkg -i /tmp/cloudflared.deb && \ |
| rm /tmp/cloudflared.deb |
|
|
| WORKDIR /app |
|
|
| RUN groupadd --system --gid 1001 exocore && \ |
| useradd --system --uid 1001 --gid exocore exocore |
|
|
| COPY --from=deps /app/node_modules ./node_modules |
| COPY --from=builder /app/exocore-web/dist ./exocore-web/dist |
| COPY --from=builder /app/exocore-web ./exocore-web |
| COPY --from=builder /app/main.ts ./main.ts |
| COPY --from=builder /app/package*.json ./ |
|
|
| COPY --from=builder /app/tsconfig*.json ./ |
|
|
| RUN mkdir -p projects uploads/temp && \ |
| chown -R exocore:exocore /app |
|
|
| USER exocore |
|
|
| ENV NODE_ENV=production |
| ENV PORT=5000 |
|
|
| EXPOSE 5000 |
|
|
| HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \ |
| CMD curl -f http://localhost:${PORT}/exocore/api/health || exit 1 |
|
|
| ENTRYPOINT ["/usr/bin/tini", "--"] |
| CMD ["node_modules/.bin/tsx", "main.ts"] |
|
|