aider/docker/Dockerfile
Paul Gauthier 711ca9df08 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.
2024-07-31 10:20:47 -03:00

43 lines
1.2 KiB
Docker

FROM python:3.10-slim AS base
RUN apt-get update && \
apt-get install --no-install-recommends -y build-essential git libportaudio2 && \
rm -rf /var/lib/apt/lists/*
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
#########################
FROM base AS aider-full
COPY . /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[help,browser,playwright] \
--extra-index-url https://download.pytorch.org/whl/cpu \
&& rm -rf /tmp/aider
RUN playwright install --with-deps chromium
ENTRYPOINT ["/venv/bin/aider"]
#########################
FROM base AS aider
COPY . /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
ENTRYPOINT ["/venv/bin/aider"]