Skip to content

Commit

Permalink
Add Docker image for Goose
Browse files Browse the repository at this point in the history
Fixes block#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).
  • Loading branch information
jasonkneen committed Feb 6, 2025
1 parent 745b671 commit c91d638
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit c91d638

Please sign in to comment.