Skip to content

Commit

Permalink
feat: Add Enclave DinD support with X11
Browse files Browse the repository at this point in the history
This commit introduces Docker-in-Docker (DinD) support for the Enclave environment, enabling the use of X11 applications within the container.

The following changes were made:

- Updated the Makefile to run Enclave as a DinD container with the Docker daemon.
- Modified the _.sh script to include necessary X11 configurations and environment variables.
- Added documentation for manual Enclave tooling setup with X11 support.
- Updated the state diagram to reflect the X11 setup step.
- Updated the Dockerfile to include X11 dependencies and configurations.
  • Loading branch information
jwalsh committed Nov 2, 2024
1 parent a87b3ab commit 3a1ef34
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 6 deletions.
11 changes: 6 additions & 5 deletions computer-use-demo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ run-enclave: ## Run Enclave as DinD container with Docker daemon
-v $(HOME)/.anthropic:/root/.anthropic \
-p 8080:8080 -p 8501:8501 -p 5900:5900 -p 6080:6080 \
docker:dind sh -c 'dockerd > /var/log/dockerd.log 2>&1 & sleep 3 && /bin/sh'
# Once inside Enclave, run ComputerUse with:
# docker run -it \
# -v /root/.anthropic:/home/computeruse/.anthropic \
# --network host \
# ghcr.io/anthropics/anthropic-quickstarts:computer-use-demo-latest

# Once inside Enclave, run ComputerUse with:
# docker run -it \
# -v /root/.anthropic:/home/computeruse/.anthropic \
# --network host \
# ghcr.io/anthropics/anthropic-quickstarts:computer-use-demo-latest

run-enclave-local: ## Run local Enclave container for testing
docker run -it --entrypoint /bin/bash enclave
Expand Down
24 changes: 24 additions & 0 deletions computer-use-demo/_enclave.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Start Enclave

# for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do apt-get remove $pkg; done

# Validation
docker run -it --net=host \
-v $HOME/.anthropic:/home/computeruse/.anthropic \
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
ubuntu:22.04 \
docker run -it \
-v /home/computeruse/.anthropic:/home/computeruse/.anthropic \
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
-p 8080:8080 -p 8501:8501 -p 5900:5900 -p 6080:6080 \
ghcr.io/anthropics/anthropic-quickstarts:computer-use-demo-latest

# Baseline
docker run \
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
-v $HOME/.anthropic:/home/computeruse/.anthropic \
-p 5900:5900 \
-p 8501:8501 \
-p 6080:6080 \
-p 8080:8080 \
-it ghcr.io/anthropics/anthropic-quickstarts:computer-use-demo-latest
44 changes: 43 additions & 1 deletion computer-use-demo/infrastructure.org
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,48 @@ RUN apk update && apk add --no-cache \

# Rest of Dockerfile remains the same...
#+end_src

*** Enclave Tooling (Manual)

#+begin_src sh
#!/bin/bash -ex

# Set environment variables
export TMPDIR="/tmp"
export PS1="\n\[\033[1;35m\](tools)\[\033[0m\] \[\033[1;32m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\] \$ "

# Install a comprehensive set of development tools (group 1)
apk add --no-cache bash curl gcc musl-dev git emacs-x11 vim tmux wget htop tree ripgrep fd jq yq python3 py3-pip nodejs npm make fzf bat exa httpie ncurses bash-completion docker-compose openssh-client pipx direnv poetry sudo xz nix aws-cli

# Install additional tools (group 2)
apk add --no-cache git jq curl make emacs imagemagick openssl openssh aws-cli coreutils sed gawk util-linux bash gnupg xclip

PYTHON_VERSION="3.12"

# Install Python (if not already installed)
apk add --no-cache python3="$PYTHON_VERSION" py3-pip="$PYTHON_VERSION"

# Install Poetry
pip install poetry

# Install Python dependencies
poetry add anthropic requests streamlit pip virtualenv psutil psycopg2-binary watchdog boto3 poetry-core


# Create directories
mkdir -p $HOME/.anthropic/{tools,backups,journal,sandbox,docs}
mkdir -p $HOME/.anthropic/journal/screenshots/$(date +%Y-%m-%d)

# Prioritize util-linux in PATH (it includes BSD utils)
export PATH="/usr/bin:$PATH" # Adjust if needed

alias pbcopy='tee ~/.anthropic/clipboard.txt | qrencode -t UTF8 -o - | tee ~/.anthropic/qrcode.txt'

# echo "$STATUS_INFO" | qrencode -t UTF8 -o - | xclip -selection clipboard
echo "🚀 Tools environment activated"

#+end_src

** ComputerUse Environment
:PROPERTIES:
:header-args:dockerfile: :tangle dockerfiles/computer-use.Dockerfile :mkdirp t
Expand Down Expand Up @@ -241,7 +283,7 @@ stateDiagram-v2
X11Setup --> VNCSetup: Start VNC
VNCSetup --> WebSetup: Start noVNC
WebSetup --> Running: Start Streamlit

Running --> [*]: Shutdown
#+end_src

Expand Down

0 comments on commit 3a1ef34

Please sign in to comment.