瀏覽代碼

feat: add workflow to ghcr (#237)

Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
iFurySt 2 年之前
父節點
當前提交
8b9fc3df28

+ 45 - 0
.github/workflows/ghcr.yml

@@ -0,0 +1,45 @@
+name: Build and publish multi-arch container images
+
+on:
+  push:
+    branches: [ main ]
+  workflow_dispatch:
+    inputs:
+      reason:
+        description: 'Why manual trigger?'
+        required: false
+        default: ''
+
+jobs:
+  ghcr_build_and_push:
+    runs-on: ubuntu-latest
+    if: github.event_name == 'push'
+
+    steps:
+      - name: checkout
+        uses: actions/checkout@v4
+
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v3
+
+      - name: Set up Docker Buildx
+        id: buildx
+        uses: docker/setup-buildx-action@v3
+
+      - name: Log-in to ghcr.io
+        run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
+
+      - name: Build and push multi-arch container images
+        run: |
+          # set env for fork repo
+          DOCKER_BUILD_ORG=$(echo "${{ github.repository }}" | tr '[A-Z]' '[a-z]' | cut -d '/' -f 1)
+          # Find directories containing Dockerfile but not containing .dockerfileignore
+          while IFS= read -r dockerfile_dir; do
+            # Check if .dockerfileignore exists in the directory
+            if [ ! -f "$dockerfile_dir/.dockerfileignore" ]; then
+              # Change directory and execute 'make all'
+              pushd "$dockerfile_dir" > /dev/null
+              make all DOCKER_BUILD_ORG=$DOCKER_BUILD_ORG
+              popd > /dev/null
+            fi
+          done < <(find . -type f -name Dockerfile -exec dirname {} \; | sort -u)

+ 0 - 0
agenthub/langchains_agent/.dockerfileignore


+ 22 - 0
agenthub/langchains_agent/Makefile

@@ -0,0 +1,22 @@
+DOCKER_BUILD_REGISTRY=ghcr.io
+DOCKER_BUILD_ORG=opendevin
+DOCKER_BUILD_REPO=eval-swe-bench
+DOCKER_BUILD_TAG=v0.1
+FULL_IMAGE=$(DOCKER_BUILD_REGISTRY)/$(DOCKER_BUILD_ORG)/$(DOCKER_BUILD_REPO):$(DOCKER_BUILD_TAG)
+LATEST_FULL_IMAGE=$(DOCKER_BUILD_REGISTRY)/$(DOCKER_BUILD_ORG)/$(DOCKER_BUILD_REPO):latest
+
+# normally, for local build testing or development. use cross platform build for sharing images to others.
+build:
+	docker build -f Dockerfile -t ${FULL_IMAGE} -t ${LATEST_FULL_IMAGE} .
+
+push:
+	docker push ${FULL_IMAGE} ${LATEST_FULL_IMAGE}
+
+test:
+	docker buildx build --platform linux/amd64 \
+	-t ${FULL_IMAGE} -t ${LATEST_FULL_IMAGE} --load -f Dockerfile .
+
+# cross platform build, you may need to manually stop the buildx(buildkit) container
+all:
+	docker buildx build --platform linux/amd64,linux/arm64 \
+	-t ${FULL_IMAGE} -t ${LATEST_FULL_IMAGE} --push -f Dockerfile .

+ 1 - 3
evaluation/SWE-bench/Dockerfile

@@ -19,7 +19,7 @@ WORKDIR /home/swe-bench
 # Setup Conda
 ENV PATH="/home/swe-bench/miniconda3/bin:${PATH}"
 ARG PATH="/home/swe-bench/miniconda3/bin:${PATH}"
-RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh \
+RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-`uname -m`.sh -O miniconda.sh \
     && mkdir ~/.conda \
     && bash miniconda.sh -b \
     && rm -f miniconda.sh
@@ -35,5 +35,3 @@ RUN pip install datasets python-dotenv gitpython
 RUN conda init bash
 
 CMD ["/bin/bash"]
-# docker build -t opendevin/eval-swe-bench:v0.1 -f evaluation/swe-bench/Dockerfile evaluation/swe-bench/
-# docker push opendevin/eval-swe-bench:v0.1

+ 1 - 1
evaluation/SWE-bench/scripts/run_docker_interactive.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 
-DOCKER_IMAGE=opendevin/eval-swe-bench:v0.1
+DOCKER_IMAGE=ghcr.io/opendevin/eval-swe-bench:v0.1
 WORK_DIR=`pwd`
 
 docker run \

+ 0 - 3
opendevin/sandbox/Dockerfile

@@ -15,6 +15,3 @@ RUN apt-get update && apt-get install -y \
     python3-dev \
     build-essential \
     && rm -rf /var/lib/apt/lists/*
-
-# docker build -f opendevin/sandbox/Dockerfile -t opendevin/sandbox:v0.1 .
-# docker push opendevin/sandbox:v0.1

+ 22 - 0
opendevin/sandbox/Makefile

@@ -0,0 +1,22 @@
+DOCKER_BUILD_REGISTRY=ghcr.io
+DOCKER_BUILD_ORG=opendevin
+DOCKER_BUILD_REPO=sandbox
+DOCKER_BUILD_TAG=v0.1
+FULL_IMAGE=$(DOCKER_BUILD_REGISTRY)/$(DOCKER_BUILD_ORG)/$(DOCKER_BUILD_REPO):$(DOCKER_BUILD_TAG)
+LATEST_FULL_IMAGE=$(DOCKER_BUILD_REGISTRY)/$(DOCKER_BUILD_ORG)/$(DOCKER_BUILD_REPO):latest
+
+# normally, for local build testing or development. use cross platform build for sharing images to others.
+build:
+	docker build -f Dockerfile -t ${FULL_IMAGE} -t ${LATEST_FULL_IMAGE} .
+
+push:
+	docker push ${FULL_IMAGE} ${LATEST_FULL_IMAGE}
+
+test:
+	docker buildx build --platform linux/amd64 \
+	-t ${FULL_IMAGE} -t ${LATEST_FULL_IMAGE} --load -f Dockerfile .
+
+# cross platform build, you may need to manually stop the buildx(buildkit) container
+all:
+	docker buildx build --platform linux/amd64,linux/arm64 \
+	-t ${FULL_IMAGE} -t ${LATEST_FULL_IMAGE} --push -f Dockerfile .

+ 1 - 1
opendevin/sandbox/sandbox.py

@@ -14,7 +14,7 @@ OutputType = namedtuple("OutputType", ["content"])
 DIRECTORY_REWRITE = os.getenv(
     "DIRECTORY_REWRITE", ""
 )  # helpful for docker-in-docker scenarios
-CONTAINER_IMAGE = os.getenv("SANDBOX_CONTAINER_IMAGE", "opendevin/sandbox:v0.1")
+CONTAINER_IMAGE = os.getenv("SANDBOX_CONTAINER_IMAGE", "ghcr.io/opendevin/sandbox:v0.1")
 # FIXME: On some containers, the devin user doesn't have enough permission, e.g. to install packages
 # How do we make this more flexible?
 RUN_AS_DEVIN = os.getenv("RUN_AS_DEVIN", "true").lower() != "false"