Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions harbor_cookbook/recipes/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
"name": "skills",
"description": "Giving agents access to custom skills via the skills_dir setting in task.toml.",
"path": "recipes/skills"
},
{
"name": "s3-mount",
"description": "Provisioning S3 data into an agent container at startup via an entrypoint and the AWS CLI.",
"path": "recipes/s3-mount"
}
]
}
55 changes: 55 additions & 0 deletions harbor_cookbook/recipes/s3-mount/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# s3-mount

Provisioning S3 data into an agent container at startup using an entrypoint that downloads via the AWS CLI.

## Structure

```
s3-mount/
├── README.md
├── task.toml # Timeouts, resources, AWS env vars
├── instruction.md # What the agent should do
├── environment/
│ ├── Dockerfile # Installs AWS CLI, sets entrypoint
│ ├── docker-compose.yaml # Injects AWS env vars into the container
│ └── entrypoint.sh # Downloads from S3 before agent starts
├── tests/
│ ├── test.sh # Installs pytest, runs tests, writes reward
│ └── test_solution.py # Pytest assertions
└── solution/
└── solve.sh # Reference solution
```

## How it works

The Dockerfile installs the AWS CLI and sets `entrypoint.sh` as the container's ENTRYPOINT. When the container starts, the entrypoint downloads the file at `$S3_DATA_URI` to `/app/data.txt`, then hands off to Harbor via `exec "$@"`. By the time the agent starts, the data is already on disk — the agent never interacts with S3 directly.

AWS credentials and the S3 URI are declared in `[environment.env]` in `task.toml`, which resolves them from the host environment at runtime. The `docker-compose.yaml` explicitly lists these variables in its `environment:` section so they are injected into the container at creation time (Harbor's base compose config does not forward `[environment.env]` vars to the container process — only to `exec` calls).

## Setup

### 1. Create an S3 bucket and upload sample data

```bash
aws s3 mb s3://harbor-s3-example
printf "10\n20\n30\n40\n50\n" | aws s3 cp - s3://harbor-s3-example/numbers.txt
```

### 2. Export AWS credentials

```bash
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
```

## Run

```bash
harbor run -p harbor_cookbook/recipes/s3-mount --agent claude-code --model anthropic/claude-sonnet-4-6
```

To use a different S3 path:

```bash
S3_DATA_URI=s3://my-bucket/my-file.txt harbor run -p harbor_cookbook/recipes/s3-mount --agent claude-code --model anthropic/claude-sonnet-4-6
```
13 changes: 13 additions & 0 deletions harbor_cookbook/recipes/s3-mount/environment/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:24.04

RUN apt-get update && apt-get install -y curl unzip && rm -rf /var/lib/apt/lists/* \
&& curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" -o /tmp/awscli.zip \
&& unzip -q /tmp/awscli.zip -d /tmp \
&& /tmp/aws/install \
&& rm -rf /tmp/aws /tmp/awscli.zip

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
WORKDIR /app
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file is merged on top of Harbor's base docker-compose config.
# It injects the AWS env vars into the main container so the
# entrypoint can download from S3 before the agent starts.
services:
main:
environment:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- S3_DATA_URI
6 changes: 6 additions & 0 deletions harbor_cookbook/recipes/s3-mount/environment/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -euo pipefail

aws s3 cp "$S3_DATA_URI" /app/data.txt

exec "$@"
1 change: 1 addition & 0 deletions harbor_cookbook/recipes/s3-mount/instruction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Read the integers from `/app/data.txt` (one per line), compute their sum, and write only the numeric result to `/app/result.txt`.
8 changes: 8 additions & 0 deletions harbor_cookbook/recipes/s3-mount/solution/solve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

sum=0
while IFS= read -r line; do
sum=$((sum + line))
done < /app/data.txt

echo "$sum" > /app/result.txt
18 changes: 18 additions & 0 deletions harbor_cookbook/recipes/s3-mount/task.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version = "1.0"

[verifier]
timeout_sec = 120.0

[agent]
timeout_sec = 120.0

[environment]
build_timeout_sec = 600.0
cpus = 1
memory_mb = 2048
storage_mb = 10240

[environment.env]
AWS_ACCESS_KEY_ID = "${AWS_ACCESS_KEY_ID}"
AWS_SECRET_ACCESS_KEY = "${AWS_SECRET_ACCESS_KEY}"
S3_DATA_URI = "${S3_DATA_URI:-s3://harbor-s3-example/numbers.txt}"
19 changes: 19 additions & 0 deletions harbor_cookbook/recipes/s3-mount/tests/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

apt-get update
apt-get install -y curl

curl -LsSf https://astral.sh/uv/0.9.7/install.sh | sh

source $HOME/.local/bin/env

uvx \
--with pytest==8.4.1 \
--with pytest-json-ctrf==0.3.5 \
pytest --ctrf /logs/verifier/ctrf.json /tests/test_solution.py -rA

if [ $? -eq 0 ]; then
echo 1 > /logs/verifier/reward.txt
else
echo 0 > /logs/verifier/reward.txt
fi
16 changes: 16 additions & 0 deletions harbor_cookbook/recipes/s3-mount/tests/test_solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pathlib import Path


def test_result_file_exists():
result_path = Path("/app/result.txt")
assert result_path.exists(), "result.txt was not created"


def test_result_is_correct():
data_path = Path("/app/data.txt")
assert data_path.exists(), "/app/data.txt not found — S3 download may have failed"
numbers = [int(line.strip()) for line in data_path.read_text().strip().splitlines()]
expected = sum(numbers)

result = Path("/app/result.txt").read_text().strip()
assert result == str(expected), f"Expected sum {expected}, got '{result}'"
Loading