Spaces:
Sleeping
Sleeping
| FROM node:18-alpine AS builder | |
| WORKDIR /app | |
| # Install dependencies | |
| COPY package.json package-lock.json ./ | |
| RUN npm ci --legacy-peer-deps | |
| # Copy source | |
| COPY public ./public | |
| COPY src ./src | |
| COPY tsconfig.json ./ | |
| # Build (warnings are ok, not errors) | |
| ENV CI=false | |
| ENV NODE_OPTIONS=--max_old_space_size=4096 | |
| ENV GENERATE_SOURCEMAP=false | |
| RUN npm run build | |
| # Confirm build succeeded | |
| RUN test -f /app/build/index.html && echo "BUILD OK" || (echo "BUILD FAILED" && exit 1) | |
| RUN ls -lah /app/build/static/js/ | head -5 | |
| # ── Serve with nginx ── | |
| FROM nginx:1.25-alpine | |
| RUN rm /etc/nginx/conf.d/default.conf | |
| COPY --from=builder /app/build /usr/share/nginx/html | |
| COPY nginx.conf /etc/nginx/conf.d/default.conf | |
| RUN mkdir -p /usr/share/nginx/html/assets /usr/share/nginx/html/outputs \ | |
| && chmod -R 777 /usr/share/nginx/html \ | |
| && chown -R nginx:nginx /usr/share/nginx/html \ | |
| && chown -R nginx:nginx /var/cache/nginx \ | |
| && chown -R nginx:nginx /var/log/nginx \ | |
| && chown -R nginx:nginx /etc/nginx/conf.d \ | |
| && touch /var/run/nginx.pid \ | |
| && chown nginx:nginx /var/run/nginx.pid | |
| USER nginx | |
| EXPOSE 7860 | |
| CMD ["nginx", "-g", "daemon off;"] | |