Added directory permission to the non-root user.
This commit is contained in:
20
Dockerfile
20
Dockerfile
@@ -12,18 +12,18 @@ WORKDIR /app
|
||||
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
|
||||
RUN pip install --upgrade --root-user-action ignore pip && pip install --root-user-action ignore --no-cache-dir -r /tmp/requirements.txt
|
||||
|
||||
COPY . .
|
||||
# 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
|
||||
|
||||
# RUN /usr/local/bin/alembic -c alembic/alembic.ini upgrade head
|
||||
# 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
|
||||
@@ -31,5 +31,9 @@ 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"]
|
||||
|
||||
Reference in New Issue
Block a user