Skip to content

Commit

Permalink
feat: add Docker support
Browse files Browse the repository at this point in the history
This commit adds Docker support to goose via a multi-stage Dockerfile that:
- Uses rust:1.75 for building
- Uses debian:bookworm-slim for runtime
- Includes required system dependencies
- Provides documentation for Docker usage

The Docker image allows running goose without installing Rust locally and
provides a consistent runtime environment.
  • Loading branch information
Ben Levy authored and Ben Levy committed Feb 5, 2025
1 parent 180dff9 commit 7ec9784
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Docker Support for Goose

This PR adds Docker support to make it easier to run goose in containerized environments.

## Changes
- Adds a Dockerfile that builds goose from source using multi-stage builds
- Documents Docker usage in README

## Testing Done
Verified the Docker image builds and runs successfully:
```bash
docker build -t goose .
docker run goose --version # Outputs: 1.0.4
```

## Technical Details
The Dockerfile uses a multi-stage build approach:
1. Build stage: Uses rust:1.75 to compile the application
2. Runtime stage: Uses debian:bookworm-slim for a minimal runtime image

Key runtime dependencies are included:
- libssl3 and ca-certificates for TLS/networking
- libdbus-1-3 for D-Bus support
- libxcb libs for X11 support

## Screenshot
N/A - CLI tool

## Motivation
Making goose available as a Docker image provides several benefits:
1. Consistent runtime environment
2. Easy deployment in containerized environments
3. No need to install Rust toolchain for running goose

## Notes
The final image size could potentially be reduced further using Alpine Linux or scratch images,
but this would require cross-compilation support. The current approach prioritizes reliability
and ease of maintenance.
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Build stage
FROM rust:1.75 as builder

WORKDIR /usr/src/goose
COPY . .

# Install required dependencies
RUN apt-get update && \
apt-get install -y pkg-config libssl-dev libdbus-1-dev && \
rm -rf /var/lib/apt/lists/*

# Build the application
RUN cargo build --release

# Runtime stage
FROM debian:bookworm-slim

WORKDIR /app

# Install runtime dependencies
RUN apt-get update && \
apt-get install -y libssl3 ca-certificates libdbus-1-3 libxcb1 libxcb-render0 libxcb-shape0 libxcb-xfixes0 && \
rm -rf /var/lib/apt/lists/*

# Copy the binary from builder
COPY --from=builder /usr/src/goose/target/release/goose /app/goose

# Set the binary as the entrypoint
ENTRYPOINT ["/app/goose"]
18 changes: 18 additions & 0 deletions documentation/docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Docker Support

You can run goose using Docker:

```bash
# Build the image
docker build -t goose .

# Run goose commands
docker run goose --version
docker run goose --help
```

### Custom Configuration
You can mount a configuration directory to persist settings:
```bash
docker run -v ~/.config/goose:/root/.config/goose goose <command>
```

0 comments on commit 7ec9784

Please sign in to comment.