Files
db-middleware/Dockerfile

38 lines
919 B
Docker

FROM python:3.12-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Set the working directory inside the container
WORKDIR /app
# Install system dependencies required for MySQL and other libraries
RUN RUN apt-get update && apt-get install -y --no-install-recommends git && \
rm -rf /var/lib/apt/lists/*
# Create a new non-root user and switch to it
RUN groupadd --system appuser && useradd --system --create-home --gid appuser appuser
COPY files/requirements.txt /tmp/requirements.txt
RUN sleep 5
# Install Python dependencies
RUN pip install --upgrade pip && pip install --no-cache-dir -r /tmp/requirements.txt
COPY . .
RUN rm files/db.sqlite -f
RUN /usr/local/bin/alembic -c alembic/alembic.ini upgrade head
# Change ownership to the new user
RUN chown -R appuser:appuser /app
# Switch to the new non-root user
USER appuser
CMD ["bash", "/app/scripts/run.sh"]