From c91d638b121f928e9710d867f03bb0d3e6e89b1f Mon Sep 17 00:00:00 2001 From: Jason Kneen Date: Thu, 6 Feb 2025 11:48:46 +0000 Subject: [PATCH] Add Docker image for Goose Fixes #1072 Add Docker image support for Goose. * **Dockerfile**: Add a `Dockerfile` to build the Goose Docker image using a multi-stage build to minimize the final image size. Install necessary dependencies, build the Goose binary, and set the entrypoint to the Goose binary. * **GitHub Actions Workflow**: Modify `.github/workflows/build-cli.yml` to add a new job for building and publishing the Docker image. Use the `docker/build-push-action` to build and push the image, set the image name and tags based on the GitHub repository and branch, and add steps to log in to Docker Hub and push the image. * **README.md**: Update `README.md` with instructions on how to pull and run the Docker image, including the Docker Hub repository URL and example commands to run the Goose Docker container. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/block/goose/issues/1072?shareId=XXXX-XXXX-XXXX-XXXX). --- .github/workflows/build-cli.yml | 25 +++++++++++++++++++++++++ Dockerfile | 28 ++++++++++++++++++++++++++++ README.md | 17 +++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 Dockerfile diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml index 77cd29c2b..977d63925 100644 --- a/.github/workflows/build-cli.yml +++ b/.github/workflows/build-cli.yml @@ -77,3 +77,28 @@ jobs: with: name: goose-${{ matrix.architecture }}-${{ matrix.target-suffix }} path: ${{ env.ARTIFACT }} + + build-and-publish-docker: + name: Build and Publish Docker Image + runs-on: ubuntu-latest + needs: build-cli + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and Push Docker Image + uses: docker/build-push-action@v3 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/goose:${{ github.ref_name }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..70b37b045 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# syntax=docker/dockerfile:1 + +# Stage 1: Build the Goose binary +FROM rust:1.56 as builder + +WORKDIR /app + +# Copy the source code and build dependencies +COPY . . + +# Build the Goose binary +RUN cargo build --release --package goose-cli + +# Stage 2: Create the final image +FROM debian:buster-slim + +WORKDIR /app + +# Install necessary dependencies +RUN apt-get update && apt-get install -y \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Copy the Goose binary from the builder stage +COPY --from=builder /app/target/release/goose /usr/local/bin/goose + +# Set the entrypoint to the Goose binary +ENTRYPOINT ["goose"] diff --git a/README.md b/README.md index 711523be9..77812e093 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,20 @@ codename goose Check out our [documentation](https://block.github.io/goose), or to try it out head to the [installation](https://block.github.io/goose/docs/getting-started/installation) instructions! +## Docker Image + +You can now pull and run the official Goose Docker image from Docker Hub. + +### Pull the Docker Image + +```sh +docker pull block/goose:latest +``` + +### Run the Docker Container + +```sh +docker run --rm -it block/goose:latest +``` + +For more advanced usage, you can mount volumes, set environment variables, and more. Refer to the Docker documentation for additional options.