better api build

This commit is contained in:
EC2 Default User 2025-06-26 08:05:22 +00:00
parent 8855e8715a
commit 4049cf15b4
2 changed files with 18 additions and 14 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
memory_files
venv
.env
.DS_Store
secrets/

View File

@ -1,14 +1,5 @@
# Frontend build stage
FROM node:18-alpine AS frontend-builder
WORKDIR /frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ ./
RUN npm run build
# Backend build stage
FROM python:3.11-slim
# Backend base stage
FROM python:3.11-slim AS backend-base
WORKDIR /app
@ -19,18 +10,30 @@ RUN apt-get update && apt-get install -y \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements files and setup
# Copy and install Python requirements
COPY requirements ./requirements/
RUN mkdir src
COPY setup.py ./
# Do an initial install to get the dependencies cached
RUN pip install -e ".[api]"
# Install the package with common dependencies
# Frontend build stage
FROM node:18-alpine AS frontend-builder
WORKDIR /frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ ./
RUN npm run build
# Final stage
FROM backend-base
# Install the package with Python source code
COPY src/ ./src/
RUN pip install -e ".[api]"
# Copy frontend build output from previous stage
# Copy frontend build output from frontend stage
COPY --from=frontend-builder /frontend/dist ./static/
# Run as non-root user