From 7ec9784059a2b3bdb033130ff6474e46fdfad10b Mon Sep 17 00:00:00 2001 From: Ben Levy Date: Tue, 4 Feb 2025 21:26:42 -0500 Subject: [PATCH] feat: add Docker support 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. --- .github/PULL_REQUEST_TEMPLATE/docker.md | 38 +++++++++++++++++++++++++ Dockerfile | 29 +++++++++++++++++++ documentation/docker.md | 18 ++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE/docker.md create mode 100644 Dockerfile create mode 100644 documentation/docker.md diff --git a/.github/PULL_REQUEST_TEMPLATE/docker.md b/.github/PULL_REQUEST_TEMPLATE/docker.md new file mode 100644 index 0000000000..7e3ef3ffbb --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/docker.md @@ -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. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..c846c7edcb --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/documentation/docker.md b/documentation/docker.md new file mode 100644 index 0000000000..a9f9f5d8a1 --- /dev/null +++ b/documentation/docker.md @@ -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 +``` \ No newline at end of file