52 lines
1.1 KiB
Docker
52 lines
1.1 KiB
Docker
# Multi-stage build for Crypto Trader
|
|
FROM node:18-alpine AS frontend-builder
|
|
|
|
WORKDIR /app/frontend
|
|
|
|
# Copy frontend files
|
|
COPY frontend/package*.json ./
|
|
RUN npm ci
|
|
|
|
COPY frontend/ ./
|
|
RUN npm run build
|
|
|
|
# Python backend
|
|
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
gcc \
|
|
g++ \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements and install Python dependencies
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Install FastAPI and uvicorn
|
|
RUN pip install --no-cache-dir fastapi uvicorn[standard] python-multipart
|
|
|
|
# Copy backend code
|
|
COPY backend/ ./backend/
|
|
COPY src/ ./src/
|
|
COPY config/ ./config/
|
|
|
|
# Copy built frontend from builder
|
|
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
|
|
|
|
# Create data directory
|
|
RUN mkdir -p /app/data
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Set environment variables
|
|
ENV PYTHONPATH=/app
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Run the application
|
|
WORKDIR /app
|
|
CMD ["python", "-m", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
|