-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.api
More file actions
38 lines (26 loc) · 1.02 KB
/
Dockerfile.api
File metadata and controls
38 lines (26 loc) · 1.02 KB
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
# =============================================================================
# API-only Dockerfile — optimized for small EC2 instances (t3a.micro/small)
# =============================================================================
# Stage 1: Build C++ render binary (static link for alpine compatibility)
FROM alpine:3.19 AS cpp-builder
RUN apk add --no-cache build-base
WORKDIR /app
COPY src/render_api.cpp src/render_api.cpp
RUN g++ -std=c++17 -O3 -static -o fractal_api src/render_api.cpp
# Stage 2: Node.js runtime with C++ binary
FROM node:20-alpine
# Sharp needs these on alpine
RUN apk add --no-cache libstdc++
# Copy statically-linked C++ binary
COPY --from=cpp-builder /app/fractal_api /usr/local/bin/fractal_api
# Setup Node.js server
WORKDIR /app/server
COPY server/package.json server/package-lock.json ./
RUN npm ci --omit=dev && npm cache clean --force
COPY server/index.js .
ENV PORT=3000
ENV FRACTAL_BIN=/usr/local/bin/fractal_api
ENV NODE_ENV=production
ENV MAX_RENDERS=2
EXPOSE 3000
CMD ["node", "index.js"]