67 lines
1.7 KiB
Docker
67 lines
1.7 KiB
Docker
# Multi-stage build: First stage builds Angular frontend
|
|
FROM node:18-alpine as frontend-builder
|
|
|
|
WORKDIR /frontend
|
|
|
|
# Copy package files first
|
|
COPY frontend/package*.json ./
|
|
|
|
# Copy .npmrc if it exists (allows using custom npm registry)
|
|
# The quickstart scripts will create this from user's .npmrc
|
|
# Using a conditional copy approach
|
|
RUN --mount=type=bind,source=frontend,target=/tmp/frontend \
|
|
if [ -f /tmp/frontend/.npmrc ]; then cp /tmp/frontend/.npmrc ./; fi
|
|
|
|
# Install dependencies inside Docker (ensures correct platform binaries)
|
|
RUN npm install
|
|
|
|
# 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
|
|
RUN apk add --no-cache \
|
|
gcc \
|
|
musl-dev \
|
|
postgresql-dev \
|
|
postgresql-client \
|
|
linux-headers \
|
|
curl
|
|
|
|
# Copy requirements and install Python dependencies
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY app/ ./app/
|
|
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
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8000/health
|
|
|
|
# Run the application
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|