Skip to content

Commit

Permalink
Merge pull request #13 from esune/fix/image-permissions
Browse files Browse the repository at this point in the history
Actually fix user permissions
  • Loading branch information
esune authored Oct 23, 2024
2 parents f14d721 + 8d6bebb commit eeaf4c3
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
FROM python:3.12-slim

# Create unprivileged user and group for service
RUN addgroup vcservice
RUN useradd -g vcservice vcservice

WORKDIR /app

# make user owner of app folder
RUN chown -R vcservice:vcservice /app
ARG uid=1001
ARG user=vcservice

# Add vcservice user
RUN useradd -U -ms /bin/bash -u $uid $user

# - In order to drop the root user, we have to make some directories writable
# to the root group as OpenShift default security model is to run the container
# under random UID.
RUN usermod -a -G 0 $user

# The root group needs access the directories under /app for the container to function in OpenShift.
RUN chown -R $user:root /app && \
chmod -R ug+rw /app

RUN pip install --no-cache-dir --upgrade pip
RUN pip install poetry
Expand All @@ -19,6 +27,6 @@ RUN poetry install --no-root --only main

COPY ../ ./

USER vcservice
USER $user

CMD ["fastapi", "run", "main.py", "--port", "8080", "--proxy-headers"]

0 comments on commit eeaf4c3

Please sign in to comment.