|
1 | | -# ---- Build stage --------- |
2 | | -FROM node:18-slim AS builder |
3 | | -ARG VERSION |
| 1 | +FROM node:20-slim AS base |
4 | 2 | WORKDIR /app |
5 | 3 |
|
6 | | -# Build arguments for configuration |
7 | | -ARG API_URL=https://testnet-deeploy-api.ratio1.ai |
8 | | -ARG ENVIRONMENT=testnet |
| 4 | +RUN apt-get update \ |
| 5 | + && apt-get install -y --no-install-recommends python3 make g++ \ |
| 6 | + && rm -rf /var/lib/apt/lists/* |
| 7 | +ENV PYTHON=python3 |
| 8 | + |
| 9 | +ARG NEXT_PUBLIC_API_URL=https://testnet-deeploy-api.ratio1.ai |
| 10 | +ARG NEXT_PUBLIC_ENVIRONMENT=testnet |
| 11 | +ARG VERSION |
9 | 12 |
|
10 | | -# Set environment variables for the build process |
11 | | -ENV VITE_API_URL=${API_URL} |
12 | | -ENV VITE_ENVIRONMENT=${ENVIRONMENT} |
| 13 | +ENV NEXT_TELEMETRY_DISABLED=1 |
| 14 | +ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} |
| 15 | +ENV NEXT_PUBLIC_ENVIRONMENT=${NEXT_PUBLIC_ENVIRONMENT} |
| 16 | +ENV NEXT_PUBLIC_APP_VERSION=${VERSION} |
13 | 17 |
|
| 18 | +FROM base AS deps |
14 | 19 | COPY package*.json ./ |
15 | 20 | RUN npm ci |
16 | 21 |
|
| 22 | +FROM base AS builder |
| 23 | +COPY package*.json ./ |
| 24 | +COPY --from=deps /app/node_modules ./node_modules |
17 | 25 | COPY . . |
18 | | -ENV VITE_APP_VERSION=${VERSION} |
19 | | -RUN npm run build # produces static files in /app/dist |
20 | | - |
21 | | -# ---- Runtime stage --------- |
22 | | -FROM nginx:alpine |
| 26 | +RUN npm run build |
| 27 | +RUN npm prune --omit=dev |
23 | 28 |
|
24 | | -COPY --from=builder /app/dist /usr/share/nginx/html |
| 29 | +FROM base AS runner |
| 30 | +ENV NODE_ENV=production |
| 31 | +ENV PORT=80 |
| 32 | +ENV HOST=0.0.0.0 |
25 | 33 |
|
26 | | -RUN sed -i '/index index\.html index\.htm;/a\ try_files \$uri \$uri/ /index.html;' \ |
27 | | - /etc/nginx/conf.d/default.conf |
| 34 | +COPY --from=builder /app/public ./public |
| 35 | +COPY --from=builder /app/.next ./.next |
| 36 | +COPY --from=builder /app/node_modules ./node_modules |
| 37 | +COPY package.json ./ |
28 | 38 |
|
29 | 39 | EXPOSE 80 |
30 | | -CMD ["nginx", "-g", "daemon off;"] |
| 40 | +CMD ["npm", "run", "start"] |
0 commit comments