feat: create virtual environment for aider installation

The changes in this commit create a virtual environment for the aider application in the Docker image. The key changes are:

1. Removes the permission-related commands that were modifying system directories.
2. Creates a virtual environment at `/venv` and adds it to the PATH.
3. Installs aider and its dependencies into the virtual environment.
4. Updates the ENTRYPOINT to use the aider executable from the virtual environment.
5. Copies the aider source to a temporary directory (`/tmp/aider`) for installation, then removes it after installation.

These changes should address the concerns about modifying system permissions while still allowing the container to function properly for different users.
This commit is contained in:
Paul Gauthier (aider) 2024-07-31 10:14:29 -03:00
parent 03243e354b
commit 67c4df09fd

View file

@ -4,38 +4,34 @@ RUN apt-get update && \
apt-get install --no-install-recommends -y build-essential git libportaudio2 && \
rm -rf /var/lib/apt/lists/*
# Permission kludges to support `docker run --user xxx`
RUN mkdir /.aider /app /.cache
RUN chmod a+rwx /.aider /app /.cache
WORKDIR /app
RUN python -m venv /venv
ENV PATH="/venv/bin:$PATH"
# So git doesn't complain about unusual permissions
RUN git config --system --add safe.directory /app
# So pip installs work
RUN chmod a+rwx /usr/local/lib/python3.10/site-packages /usr/local/*
WORKDIR /app
#########################
FROM base AS aider-full
COPY . /aider
COPY . /tmp/aider
RUN pip install --upgrade pip \
&& pip install --no-cache-dir /aider[help,browser,playwright] \
&& pip install --no-cache-dir /tmp/aider[help,browser,playwright] \
--extra-index-url https://download.pytorch.org/whl/cpu \
&& rm -rf /aider
&& rm -rf /tmp/aider
RUN playwright install --with-deps chromium
ENTRYPOINT ["aider"]
ENTRYPOINT ["/venv/bin/aider"]
#########################
FROM base AS aider
COPY . /aider
COPY . /tmp/aider
RUN pip install --upgrade pip \
&& pip install --no-cache-dir /aider \
&& pip install --no-cache-dir /tmp/aider \
--extra-index-url https://download.pytorch.org/whl/cpu \
&& rm -rf /aider
&& rm -rf /tmp/aider
ENTRYPOINT ["aider"]
ENTRYPOINT ["/venv/bin/aider"]