-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (55 loc) · 1.89 KB
/
Copy pathDockerfile
File metadata and controls
73 lines (55 loc) · 1.89 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
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
67
68
69
70
71
72
73
# Build stage - Force x86_64 platform for FFI compatibility
# Using Ubuntu 24.04 for glibc 2.39 which is compatible with the FFI library
FROM --platform=linux/amd64 ubuntu:24.04 AS builder
# Install Node.js and build tools
RUN apt-get update && apt-get install -y \
curl \
ca-certificates \
cmake \
make \
g++ \
python3 \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy SDK to correct relative path (for file:../../sdk/javascript in package.json)
COPY sdk/javascript /app/sdk/javascript
# Copy demo app
COPY demo/e-commerce/package.json /app/demo/e-commerce/
COPY demo/e-commerce/tsconfig.json /app/demo/e-commerce/
# Install dependencies
WORKDIR /app/demo/e-commerce
RUN npm install
# Copy source code
COPY demo/e-commerce/server ./server
# Build TypeScript
RUN npm run build
# Production stage - Force x86_64 platform for FFI compatibility
# Using Ubuntu 24.04 for glibc 2.39 which is compatible with the FFI library
FROM --platform=linux/amd64 ubuntu:24.04 AS production
# Install Node.js (production only needs runtime, not build tools)
RUN apt-get update && apt-get install -y \
curl \
ca-certificates \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy SDK for production
COPY sdk/javascript /app/sdk/javascript
# Copy package.json and install production deps
COPY demo/e-commerce/package.json /app/demo/e-commerce/
WORKDIR /app/demo/e-commerce
RUN npm install --omit=dev
# Copy built files from builder
COPY --from=builder /app/demo/e-commerce/dist ./dist
# Copy client files for static serving
COPY demo/e-commerce/client ./client
# Expose port
EXPOSE 3000
# Set environment
ENV NODE_ENV=production
ENV PORT=3000
# Start server
CMD ["node", "dist/index.js"]