# Use official Python 3.2 image | |
FROM python:3.2 | |
# Set working directory to /app (root of the repository) | |
WORKDIR /app | |
# Copy requirements file | |
COPY ./requirements.txt /app/requirements.txt | |
# Install dependencies from requirements.txt only | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Copy the entire project | |
COPY . /app | |
# Create user if it doesn't exist, then switch to it and pre-create log file | |
RUN id -u user &>/dev/null || useradd -m -u 1000 user | |
RUN mkdir -p /home/user && touch /home/user/app.log && chown user:user /home/user/app.log | |
USER user | |
ENV HOME=/home/user \ | |
PATH=/home/user/.local/bin:$PATH | |
# Expose port | |
EXPOSE 7860 | |
# Command to run the app with debug logging and custom log file | |
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port 7860 --log-level debug --log-config log_config.json"] |