35 lines
776 B
Docker
35 lines
776 B
Docker
# Use Python 3.9 slim image as base
|
|
FROM python:3.9-slim
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Set environment variables
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements file
|
|
COPY requirements.txt .
|
|
|
|
# Install Python dependencies
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Create a non-root user
|
|
RUN useradd --create-home --shell /bin/bash app \
|
|
&& chown -R app:app /app
|
|
USER app
|
|
|
|
# Expose port for web interface
|
|
EXPOSE 8000
|
|
|
|
# Command to run the FastAPI web app
|
|
CMD ["uvicorn", "web.app:app", "--host", "0.0.0.0", "--port", "8000"] |