mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-17 22:24:21 +01:00
feat: Build Goose in a Docker Container (#1551)
This commit is contained in:
111
documentation/docs/docker/Dockerfile
Normal file
111
documentation/docs/docker/Dockerfile
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
# Build stage
|
||||||
|
FROM rust:bullseye AS builder
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-c"]
|
||||||
|
|
||||||
|
# Install Node.js and any missing dependencies
|
||||||
|
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
|
||||||
|
apt-get update && apt-get install -y \
|
||||||
|
nodejs \
|
||||||
|
libdbus-1-dev \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Create a new directory for the app
|
||||||
|
WORKDIR /usr/src/goose
|
||||||
|
|
||||||
|
# Copy the entire project
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
RUN cargo build --release
|
||||||
|
|
||||||
|
# Runtime stage
|
||||||
|
FROM ubuntu:22.04
|
||||||
|
|
||||||
|
# Configure non-interactive installation
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
# Install runtime libraries with DBus and keyring support
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
# Runtime dependencies
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
gnupg \
|
||||||
|
# DBus and keyring
|
||||||
|
dbus \
|
||||||
|
dbus-x11 \
|
||||||
|
gnome-keyring \
|
||||||
|
libsecret-1-0 \
|
||||||
|
libsecret-tools \
|
||||||
|
# Other dependencies
|
||||||
|
libssl3 \
|
||||||
|
libxcb1 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install Node.js
|
||||||
|
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
|
||||||
|
apt-get update && apt-get install -y nodejs && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install common development tools
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
# Version control
|
||||||
|
git \
|
||||||
|
# Text processing and search
|
||||||
|
ripgrep \
|
||||||
|
fd-find \
|
||||||
|
fzf \
|
||||||
|
# File manipulation
|
||||||
|
jq \
|
||||||
|
# Network tools
|
||||||
|
wget \
|
||||||
|
# Process management
|
||||||
|
htop \
|
||||||
|
# System utilities
|
||||||
|
sudo \
|
||||||
|
# Text editors
|
||||||
|
nano \
|
||||||
|
vim \
|
||||||
|
# Archive tools
|
||||||
|
zip \
|
||||||
|
unzip \
|
||||||
|
# Build essentials
|
||||||
|
build-essential \
|
||||||
|
# Python
|
||||||
|
python3 \
|
||||||
|
python3-pip \
|
||||||
|
# Additional tools
|
||||||
|
tree \
|
||||||
|
tmux \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install uv using curl
|
||||||
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||||
|
|
||||||
|
# Copy the built binaries
|
||||||
|
COPY --from=builder /usr/src/goose/target/release/goose /usr/local/bin/
|
||||||
|
|
||||||
|
# Create a wrapper script to initialize DBus and keyring
|
||||||
|
RUN echo '#!/bin/bash\n\
|
||||||
|
# Start DBus session daemon if not running\n\
|
||||||
|
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then\n\
|
||||||
|
eval $(dbus-launch --sh-syntax)\n\
|
||||||
|
export DBUS_SESSION_BUS_ADDRESS\n\
|
||||||
|
fi\n\
|
||||||
|
\n\
|
||||||
|
# Initialize keyring if needed\n\
|
||||||
|
if [ -z "$GNOME_KEYRING_CONTROL" ]; then\n\
|
||||||
|
eval $(gnome-keyring-daemon --start)\n\
|
||||||
|
export GNOME_KEYRING_CONTROL SSH_AUTH_SOCK\n\
|
||||||
|
fi\n\
|
||||||
|
\n\
|
||||||
|
' > /usr/local/bin/entrypoint.sh && \
|
||||||
|
chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
# Set up some basic git config
|
||||||
|
RUN git config --global init.defaultBranch main && \
|
||||||
|
git config --global core.editor "vim"
|
||||||
|
|
||||||
|
# Add some helpful aliases
|
||||||
|
RUN echo 'alias ll="ls -la"' >> ~/.bashrc && \
|
||||||
|
echo 'alias fd=fdfind' >> ~/.bashrc
|
||||||
36
documentation/docs/docker/docker-compose.yml
Normal file
36
documentation/docs/docker/docker-compose.yml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
services:
|
||||||
|
goose-cli:
|
||||||
|
build:
|
||||||
|
context: ../../..
|
||||||
|
dockerfile: documentation/docs/docker/Dockerfile
|
||||||
|
args:
|
||||||
|
USER_ID: ${UID:-1000}
|
||||||
|
volumes:
|
||||||
|
# Mount user's directory with read-write access
|
||||||
|
- ../../..:/root/workspace
|
||||||
|
- goose-config:/root/.goose
|
||||||
|
# Mount git config
|
||||||
|
- ~/.gitconfig:/root/.gitconfig:ro
|
||||||
|
# Mount SSH keys
|
||||||
|
- ~/.ssh:/root/.ssh:ro
|
||||||
|
working_dir: /root/workspace
|
||||||
|
environment:
|
||||||
|
- OOSE_HOME=/root/.goose
|
||||||
|
# Set default editor
|
||||||
|
- EDITOR=vim
|
||||||
|
# Preserve git author info
|
||||||
|
- GIT_AUTHOR_NAME=${GIT_AUTHOR_NAME:-Goose User}
|
||||||
|
- GIT_AUTHOR_EMAIL=${GIT_AUTHOR_EMAIL:-goose@example.com}
|
||||||
|
# Set GOOGLE_API_KEY to your own API key
|
||||||
|
- GOOGLE_API_KEY="XXX"
|
||||||
|
- GOOSE_PROVIDER=google
|
||||||
|
- GOOSE_MODEL=gemini-2.0-flash-exp
|
||||||
|
- DBUS_SESSION_BUS_ADDRESS
|
||||||
|
- GNOME_KEYRING_CONTROL
|
||||||
|
- SSH_AUTH_SOCK
|
||||||
|
stdin_open: true
|
||||||
|
tty: true
|
||||||
|
entrypoint: ["/bin/bash"]
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
goose-config:
|
||||||
49
documentation/docs/guides/goose-in-docker.md
Normal file
49
documentation/docs/guides/goose-in-docker.md
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
title: Goose in Docker
|
||||||
|
sidebar_position: 3
|
||||||
|
---
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
|
:::info Tell Us What You Need
|
||||||
|
There are various scenarios where you might want to build Goose in Docker. If the instructions below do not meet your needs, please contact us by replying to our [discussion topic](https://github.com/block/goose/discussions/1496).
|
||||||
|
:::
|
||||||
|
# Use Case 1: Building Goose from the source in Docker
|
||||||
|
|
||||||
|
As a Goose user and developer, you can build Goose from the source file within a Docker container. This approach not only provides security benefits by creating an isolated environment but also enhances consistency and portability. For example, if you need to troubleshoot an error on a platform you don't usually work with (such as Ubuntu), you can easily debug it using Docker.
|
||||||
|
|
||||||
|
To begin, you will need to modify the `Dockerfile` and `docker-compose.yml` files to suit your requirements. Some changes you might consider include:
|
||||||
|
- Setting your API key, provider, and model in the `docker-compose.yml` file. Our example uses the Google API key and its corresponding settings, but you can find your own list of API keys [here](https://github.com/block/goose/blob/main/ui/desktop/src/components/settings/models/hardcoded_stuff.tsx#L86-L94) and the corresponding settings [here](https://github.com/block/goose/blob/main/ui/desktop/src/components/settings/models/hardcoded_stuff.tsx#L67-L77).
|
||||||
|
- Changing the base image to a different Linux distribution in the `Dockerfile`. Our example uses Ubuntu, but you can switch to another distribution such as CentOS, Fedora, or Alpine.
|
||||||
|
- Mounting your personal Goose settings and hints files in the `docker-compose.yml` file. This allows you to use your personal settings and hints files within the Docker container.
|
||||||
|
|
||||||
|
Among these, only the first change is mandatory. We need to set the API key, provider, and model as environment variables because the keyring settings do not work on Ubuntu in Docker.
|
||||||
|
|
||||||
|
After setting the credentials, you can build the Docker image using the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose -f documentation/docs/docker/docker-compose.yml build
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, run the container and connect to it using the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose -f documentation/docs/docker/docker-compose.yml run --rm goose-cli
|
||||||
|
```
|
||||||
|
Inside the container, first try to run the following command to configure Goose:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
goose configure
|
||||||
|
```
|
||||||
|
When prompted to save the API key to the keyring, select No, as we are already passing the API key as an environment variable.
|
||||||
|
|
||||||
|
Then, you can configure Goose a second time, and this time, you can add extensions:
|
||||||
|
```bash
|
||||||
|
goose configure
|
||||||
|
```
|
||||||
|
For example, you can add the `Developer` extension. After that, you can start a session:
|
||||||
|
```bash
|
||||||
|
goose session
|
||||||
|
```
|
||||||
|
You should now be able to connect to Goose with the developer extension enabled. Follow the other tutorials if you want to enable more extensions.
|
||||||
Reference in New Issue
Block a user