39 lines
899 B
Docker
39 lines
899 B
Docker
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Set environment variables
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PYTHONPATH=/app
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements
|
|
COPY requirements.txt .
|
|
|
|
# Install Python dependencies
|
|
RUN pip install --no-cache-dir --upgrade pip && \
|
|
pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy project files
|
|
COPY . .
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p /app/storage/db /app/storage/logs /app/storage/product_images /app/storage/user_images
|
|
|
|
# Set permissions
|
|
RUN chmod +x /app/scripts/lint.sh
|
|
|
|
# Initialize the database
|
|
RUN python -m app.utils.db_init
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Command to run the application
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] |