remove nginx, serve ui from api itself

This commit is contained in:
pratik
2025-10-15 14:22:44 -05:00
parent d3a14a2b31
commit 4a84c08a2b
7 changed files with 91 additions and 45 deletions

View File

@@ -1,15 +1,39 @@
# Multi-stage build: First stage builds Angular frontend
FROM node:18-alpine as frontend-builder
# Install dependencies for native modules
RUN apk add --no-cache python3 make g++
WORKDIR /frontend
# Copy package files first for better layer caching
COPY frontend/package*.json ./
# Clean install dependencies
RUN npm ci --force
# Copy frontend source
COPY frontend/src ./src
COPY frontend/public ./public
COPY frontend/angular.json ./
COPY frontend/tsconfig*.json ./
# Build the Angular app for production
RUN npm run build
# Second stage: Python backend with Angular static files
FROM python:3.11-alpine
WORKDIR /app
# Install system dependencies for Alpine
# Alpine uses apk instead of apt-get and is lighter/faster
RUN apk add --no-cache \
gcc \
musl-dev \
postgresql-dev \
postgresql-client \
linux-headers
linux-headers \
curl
# Copy requirements and install Python dependencies
COPY requirements.txt .
@@ -21,6 +45,9 @@ COPY utils/ ./utils/
COPY alembic/ ./alembic/
COPY alembic.ini .
# Copy Angular build from frontend-builder stage
COPY --from=frontend-builder /frontend/dist/frontend/browser ./static
# Create non-root user (Alpine uses adduser instead of useradd)
RUN adduser -D -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
@@ -30,7 +57,7 @@ EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:8000/health')"
CMD curl -f http://localhost:8000/health
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]