From 62e9c7824308c8795f2eafabe1b12127fb95bc74 Mon Sep 17 00:00:00 2001 From: Allison Thackston Date: Fri, 17 Feb 2023 20:26:06 +0000 Subject: [PATCH] Better support running the docker as a user --- Dockerfile | 15 ++++----------- docker/entrypoint.sh | 8 +++++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index c41cee2ae..ec82524a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,5 @@ FROM python:3.11 -ENV VIRTUAL_ENV=/opt/venv -RUN python3 -m venv $VIRTUAL_ENV -ENV PATH="$VIRTUAL_ENV/bin:$PATH" - RUN apt-get update && apt-get -y install --no-install-recommends bats gcc \ git \ git-lfs \ @@ -14,8 +10,7 @@ RUN apt-get update && apt-get -y install --no-install-recommends bats gcc \ libjpeg-dev \ libpng-dev \ libz-dev \ - && pip install --upgrade pip \ - && pip install --no-cache-dir mkdocs-material mike pillow cairosvg + vim WORKDIR /tmp COPY mkdocs_simple_plugin mkdocs_simple_plugin @@ -24,11 +19,9 @@ COPY VERSION VERSION COPY setup.py setup.py COPY pyproject.toml pyproject.toml -RUN pip install --no-cache-dir . \ - && rm -rf /tmp/* - -RUN git config --global --add safe.directory /docs &&\ - git config --global --add safe.directory /site +RUN pip install --upgrade pip \ + && pip install --no-cache-dir . \ + && pip install --no-cache-dir mkdocs-material mike pillow cairosvg WORKDIR /docs diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 1036ad65e..ab7e9c98a 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,8 +1,14 @@ #!/bin/bash set -e +git config --global --add safe.directory /docs + if [ -f "requirements.txt" ]; then - pip install -r requirements.txt + if [ "$UID" -eq 0 ]; then + pip install -r requirements.txt + else + pip install --user -r requirements.txt + fi fi exec "$@"