FROM node:20-bookworm-slim AS deps WORKDIR /app COPY frontend/package*.json ./frontend/ RUN cd frontend && npm ci || npm install FROM node:20-bookworm-slim AS builder WORKDIR /app COPY --from=deps /app/frontend/node_modules ./frontend/node_modules COPY frontend ./frontend ENV NEXT_PUBLIC_API_URL=/api ENV NEXT_PUBLIC_API_BASE_URL=/api ENV NEXT_PUBLIC_BACKEND_URL=/api WORKDIR /app/frontend RUN npm run build FROM node:20-bookworm-slim RUN apt-get update && apt-get install -y nginx gettext-base bash && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY --from=builder /app/frontend ./frontend COPY nginx.space.conf /etc/nginx/templates/nginx.space.conf.template COPY scripts/start_hf_space.sh /app/scripts/start_hf_space.sh RUN sed -i 's/\r$//' /app/scripts/start_hf_space.sh && chmod +x /app/scripts/start_hf_space.sh ENV NODE_ENV=production ENV BACKEND_ORIGIN=http://129.212.185.232:8080 EXPOSE 7860 CMD ["/app/scripts/start_hf_space.sh"]