Build your own agent Docker image
This section is about modifying the Docker image in which we run the commands suggested by the agent.
There are two reasons to build your own Docker image
- You need a very specific environment to install your package (anything that you cannot simply install inside of a conda environment)
- You want to pre-install your package for speedup.
There are three steps involved:
- Modify the
swe.Dockerfile
Dockerfile (also shown below). We provide some extended explanation of the Dockerfile here. - Build the image. One way is to simply run
./setup.sh
. Alternatively, especially if you want to change the default tag (sweagent/swe-agent:latest
), rundocker build -t "YOUR TAG HERE" -f docker/swe.Dockerfile \ --build-arg TARGETARCH=$(uname -m) .
- Make sure you use the new image by passing the
--image_name
flag torun.py
.
Default Dockerfile:
FROM ubuntu:jammy
ARG TARGETARCH
# Install third party tools
RUN apt-get update && \
apt-get install -y bash gcc git jq wget g++ make && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Initialize git
RUN git config --global user.email "sweagent@pnlp.org"
RUN git config --global user.name "sweagent"
# Environment variables
ENV ROOT='/dev/'
RUN prompt() { echo " > "; };
ENV PS1="> "
# Create file for tracking edits, test patch
RUN touch /root/files_to_edit.txt
RUN touch /root/test.patch
# add ls file indicator
RUN echo "alias ls='ls -F'" >> /root/.bashrc
# Install miniconda
ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"
COPY docker/getconda.sh .
RUN bash getconda.sh ${TARGETARCH} \
&& rm getconda.sh \
&& mkdir /root/.conda \
&& bash miniconda.sh -b \
&& rm -f miniconda.sh
RUN conda --version \
&& conda init bash \
&& conda config --append channels conda-forge
# Cache python versions
RUN conda create -y -n python3.9 python=3.9
RUN conda create -y -n python3.10 python=3.10
# Install python packages
COPY docker/requirements.txt /root/requirements.txt
RUN pip install -r /root/requirements.txt
WORKDIR /
CMD ["/bin/bash"]