This commit is contained in:
CaffeineFueled 2025-04-10 21:40:30 +02:00
commit 0e3323b7ab
13 changed files with 1625 additions and 0 deletions

41
Dockerfile Normal file
View file

@ -0,0 +1,41 @@
# Use Python 3.11 slim image for a smaller footprint
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
HOME=/home/appuser \
APP_HOME=/home/appuser/app
# Create non-root user and setup directories
RUN groupadd -g 1000 appgroup && \
useradd -m -u 1000 -g appgroup -s /bin/bash -d ${HOME} appuser && \
mkdir -p ${APP_HOME} && \
mkdir -p ${APP_HOME}/logs && \
mkdir -p ${APP_HOME}/templates && \
chown -R appuser:appgroup ${HOME}
# Set the working directory
WORKDIR ${APP_HOME}
# Install dependencies
COPY --chown=appuser:appgroup requirements.txt ${APP_HOME}/
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY --chown=appuser:appgroup main.py ${APP_HOME}/
COPY --chown=appuser:appgroup templates/ ${APP_HOME}/templates/
# Create a volume for logs
VOLUME ["${APP_HOME}/logs"]
# Switch to non-root user
USER appuser
# Expose port
EXPOSE 8000
# Command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]