Files
db-middleware/Dockerfile

40 lines
1.1 KiB
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 apt-get update && apt-get install -y --no-install-recommends git && \
rm -rf /var/lib/apt/lists/*
COPY files/requirements.txt /tmp/requirements.txt
# Install Python dependencies
RUN pip install --upgrade --root-user-action ignore pip && pip install --root-user-action ignore --no-cache-dir -r /tmp/requirements.txt
# 1. First, create the SHARED GROUP with the SAME GID as on the host
# (Replace 2000 with the GID you used on the host for 'dbmiddleware')
RUN groupadd -g 2000 dbmiddleware
# 2. Create the app user and add it to BOTH its primary group AND the shared group
RUN useradd --system --create-home appuser && \
usermod -aG dbmiddleware appuser
# Change ownership to the new user
RUN chown -R appuser:appuser /app
# Switch to the new non-root user
USER appuser
COPY . .
# RUN /usr/local/bin/alembic -c alembic/alembic.ini upgrade head
ENTRYPOINT ["bash", "/app/scripts/run.sh"]