Spaces:
Build error
Build error
# Use Node.js as base image since it's needed for the web build | |
FROM node:20.11-alpine3.19 AS web-builder | |
# Set working directory for web | |
WORKDIR /app/web | |
# Copy package files first | |
COPY web/package.json web/yarn.lock ./ | |
# Install ALL dependencies (including dev dependencies) needed for build | |
RUN yarn install --frozen-lockfile | |
# Copy web source files | |
COPY web/ . | |
# Build web app with optimizations | |
ENV NODE_ENV=production | |
ENV NEXT_TELEMETRY_DISABLED=1 | |
RUN yarn build | |
# Python base image for final stage | |
FROM python:3.10-slim-bookworm | |
# Install only essential dependencies | |
RUN apt-get update && apt-get install -y \ | |
nodejs \ | |
npm \ | |
--no-install-recommends && \ | |
rm -rf /var/lib/apt/lists/* | |
# Set working directory | |
WORKDIR /app | |
# Copy API files | |
COPY api/ /app/api/ | |
# Install Python dependencies efficiently | |
WORKDIR /app/api | |
RUN pip install --no-cache-dir poetry && \ | |
poetry config virtualenvs.create false && \ | |
poetry install --only main --no-interaction --no-ansi | |
# Copy built web files from builder stage | |
COPY --from=web-builder /app/web/.next /app/web/.next | |
COPY --from=web-builder /app/web/public /app/web/public | |
COPY --from=web-builder /app/web/node_modules /app/web/node_modules | |
COPY --from=web-builder /app/web/package.json /app/web/package.json | |
# Set environment variables | |
ENV FLASK_APP=app.py \ | |
EDITION=SELF_HOSTED \ | |
DEPLOY_ENV=PRODUCTION \ | |
CONSOLE_API_URL=http://127.0.0.1:5001 \ | |
CONSOLE_WEB_URL=http://127.0.0.1:3000 \ | |
SERVICE_API_URL=http://127.0.0.1:5001 \ | |
APP_WEB_URL=http://127.0.0.1:3000 \ | |
NODE_ENV=production | |
# Expose ports | |
EXPOSE 3000 5001 | |
# Copy and setup entrypoint script | |
COPY docker/entrypoint.sh /entrypoint.sh | |
RUN chmod +x /entrypoint.sh | |
# Start services | |
CMD ["/entrypoint.sh"] |