feat(docker): add permissions kludges to support docker run --user xxx

The changes in this commit add some permission kludges to the Docker image to support running the container with the `--user` flag. Specifically, it:

- Adds permissions to the virtual environment directory and subdirectories to allow read/write/execute access for all users.
- Creates the `.aider` and `.cache` directories and grants read/write/execute access to all users.

This ensures that the container can be run with a non-root user without encountering permission issues.
This commit is contained in:
Paul Gauthier 2024-07-31 10:20:47 -03:00 committed by Paul Gauthier (aider)
parent 67c4df09fd
commit 711ca9df08

View file

@ -9,6 +9,12 @@ WORKDIR /app
RUN python -m venv /venv
ENV PATH="/venv/bin:$PATH"
# Permission kludges to support `docker run --user xxx`
RUN chmod a+rwx /venv /venv/{bin,include,lib,lib/python3.1/site-packages}
RUN mkdir /.aider /.cache
RUN chmod a+rwx /.aider /.cache
# So git doesn't complain about unusual permissions
RUN git config --system --add safe.directory /app
@ -16,8 +22,8 @@ RUN git config --system --add safe.directory /app
FROM base AS aider-full
COPY . /tmp/aider
RUN pip install --upgrade pip \
&& pip install --no-cache-dir /tmp/aider[help,browser,playwright] \
RUN /venv/bin/python -m pip install --upgrade --no-cache-dir pip \
&& /venv/bin/python -m pip install --no-cache-dir /tmp/aider[help,browser,playwright] \
--extra-index-url https://download.pytorch.org/whl/cpu \
&& rm -rf /tmp/aider
@ -29,8 +35,8 @@ ENTRYPOINT ["/venv/bin/aider"]
FROM base AS aider
COPY . /tmp/aider
RUN pip install --upgrade pip \
&& pip install --no-cache-dir /tmp/aider \
RUN /venv/bin/python -m pip install --upgrade --no-cache-dir pip \
&& /venv/bin/python -m pip install --no-cache-dir /tmp/aider \
--extra-index-url https://download.pytorch.org/whl/cpu \
&& rm -rf /tmp/aider