π OpenHands: AI-Driven Development
Install docker in the OpenHands app image (#4283)
mamoodi2d2d3ccfa5f1
diff --git a/.github/workflows/ghcr-build.yml b/.github/workflows/ghcr-build.ymlindex 86687c5144..89c313cbec 100644--- a/.github/workflows/ghcr-build.yml+++ b/.github/workflows/ghcr-build.yml@@ -78,12 +78,19 @@ jobs:export REPO_OWNER=${{ github.repository_owner }}REPO_OWNER=$(echo $REPO_OWNER | tr '[:upper:]' '[:lower:]')# Run the build script in the app image- docker run -e SANDBOX_USER_ID=0 -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/${REPO_OWNER}/openhands:$RELEVANT_SHA /bin/bash -c "mkdir -p containers/runtime; python3 openhands/runtime/utils/runtime_build.py --base_image ${{ env.BASE_IMAGE_FOR_HASH_EQUIVALENCE_TEST }} --build_folder containers/runtime --force_rebuild" 2>&1 | tee docker-outputs.txt+ docker run -e SANDBOX_USER_ID=0 -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/${REPO_OWNER}/openhands:${{ env.RELEVANT_SHA }} /bin/bash -c "mkdir -p containers/runtime; python3 openhands/runtime/utils/runtime_build.py --base_image ${{ env.BASE_IMAGE_FOR_HASH_EQUIVALENCE_TEST }} --build_folder containers/runtime --force_rebuild" 2>&1 | tee docker-outputs.txt# Get the hash from the build scripthash_from_app_image=$(cat docker-outputs.txt | grep "Hash for docker build directory" | awk -F "): " '{print $2}' | uniq | head -n1)echo "hash_from_app_image=$hash_from_app_image" >> $GITHUB_OUTPUTecho "Hash from app image: $hash_from_app_image"+ # This test should move when we have a test suite for the app image+ - name: Test docker in App Image+ run: |+ # Lowercase the repository owner+ export REPO_OWNER=${{ github.repository_owner }}+ REPO_OWNER=$(echo $REPO_OWNER | tr '[:upper:]' '[:lower:]')+ docker run -e SANDBOX_USER_ID=0 -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/${REPO_OWNER}/openhands:${{ env.RELEVANT_SHA }} /bin/bash -c "docker run hello-world"# Builds the runtime Docker imagesghcr_build_runtime:diff --git a/containers/app/Dockerfile b/containers/app/Dockerfileindex 6df4fda5a3..ce2c0ba75c 100644--- a/containers/app/Dockerfile+++ b/containers/app/Dockerfile@@ -28,7 +28,7 @@ COPY ./pyproject.toml ./poetry.lock ./RUN touch README.mdRUN export POETRY_CACHE_DIR && poetry install --without evaluation,llama-index --no-root && rm -rf $POETRY_CACHE_DIR-FROM python:3.12.3-slim AS runtime+FROM python:3.12.3-slim AS openhands-appWORKDIR /app@@ -46,6 +46,14 @@ RUN mkdir -p $WORKSPACE_BASERUN apt-get update -y \&& apt-get install -y curl ssh sudo+# Install Docker - https://docs.docker.com/engine/install/debian/+RUN apt-get install ca-certificates curl \+ && curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc \+ && chmod a+r /etc/apt/keyrings/docker.asc \+ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null \+ && apt-get update \+ && apt install -y docker-ce+# Default is 1000, but OSX is often 501RUN sed -i 's/^UID_MIN.*/UID_MIN 499/' /etc/login.defs# Default is 60000, but we've seen up to 200000