File size: 1,714 Bytes
b069305
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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"]