Deploy walkerOS to Bunny Magic Containers
This guide deploys a walkerOS event collector to Bunny Magic Containers, forwarding events to BigQuery. We use GitHub Container Registry (GHCR) to store the Docker image privately.
Prerequisites
- GitHub account (for private container registry)
- Bunny.net account with Magic Containers access
- Docker installed
- Node.js 18+ installed
1. Set Up BigQuery
Follow the GCP BigQuery setup to:
- Create a BigQuery dataset
- Create a service account with write permissions
- Download a service account key (
sa-bigquery.json)
The key file will be baked into your Docker image. Keep the image in a private registry only.
2. Bundle the Flow
Install the CLI and bundle the flow:
npm install -g @walkeros/cli
# Set your environment variables
export GCP_PROJECT_ID="your-project-id"
export BQ_DATASET="walkerOS"
export BQ_TABLE="events"
export BQ_LOCATION="EU"
# Use the container path - variables are substituted at bundle time
export SA_KEY_PATH="/app/sa-bigquery.json"
# Bundle the flow
walkeros bundle https://www.walkeros.io/flows/gcp-bigquery.json
This creates dist/bundle.mjs with the credentials path baked in.
Test your flow before building Docker using push --simulate with a local credentials path:
export SA_KEY_PATH="./sa-bigquery.json"
walkeros push https://www.walkeros.io/flows/gcp-bigquery.json \
-e '{"name": "test", "data": {}}' --simulate destination.bigquery
3. Build Docker Image
Create a Dockerfile:
FROM walkeros/flow:latest
# Copy pre-built flow bundle
COPY dist/bundle.mjs /app/flow/bundle.mjs
# Copy service account credentials
COPY sa-bigquery.json /app/sa-bigquery.json
# Configure runtime
ENV FLOW=/app/flow/bundle.mjs
EXPOSE 8080
Build the image with your GitHub Container Registry tag:
# Replace YOUR_GITHUB_USERNAME with your GitHub username (lowercase)
docker build -t ghcr.io/YOUR_GITHUB_USERNAME/walkeros-collector:latest .
4. Test Locally
Run the container locally to verify everything works:
docker run --rm -p 8080:8080 ghcr.io/YOUR_GITHUB_USERNAME/walkeros-collector:latest
In another terminal, send a test event:
curl -X POST http://localhost:8080/collect \
-H "Content-Type: application/json" \
-d '{
"name": "page view",
"data": {
"title": "Local Test",
"path": "/test"
}
}'
Expected response:
{ "success": true, "timestamp": 1234567890 }
Verify in BigQuery:
bq query --use_legacy_sql=false \
"SELECT * FROM walkerOS.events ORDER BY timestamp DESC LIMIT 5"
5. Push to Private GHCR
Create GitHub Personal Access Token
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click Generate new token (classic)
- Name it
ghcr-walkeros - Select scopes:
write:packages(to push images)read:packages(to pull images)delete:packages(optional, for cleanup)
- Click Generate token
- Copy the token (you won't see it again)
Login and Push
# Login to GHCR
echo YOUR_GITHUB_TOKEN | docker login ghcr.io -u YOUR_GITHUB_USERNAME --password-stdin
# Push the image
docker push ghcr.io/YOUR_GITHUB_USERNAME/walkeros-collector:latest
Verify Image is Private
- Go to
https://github.com/YOUR_GITHUB_USERNAME?tab=packages - Find
walkeros-collector - Confirm visibility is Private (default for new packages)
If the package is public, click Package settings → Change visibility → Private.
6. Connect GHCR to Bunny
Create Read-Only Token for Bunny
For security, create a separate token with read-only access:
- Go to GitHub Settings → Personal access tokens
- Generate new token with only
read:packagesscope - Name it
bunny-ghcr-readonly
Add Registry to Bunny
- Log in to bunny.net dashboard
- Navigate to Magic Containers → Image Registries
- Click Add Image Registry
- Select GitHub from the dropdown
- Enter:
- Username: Your GitHub username
- Personal Access Token: The read-only token from above
- Click Save
7. Deploy to Bunny Magic Containers
Create New App
- In Bunny dashboard, go to Magic Containers
- Click Add App
- Enter app name:
walkeros-collector - Select deployment type:
- Magic (recommended) - AI auto-scales across regions
- Single Region - Deploy to one region
- Click Next
Add Container
- Click Add Container
- Enter container name:
collector - Select your GitHub registry
- Select image:
walkeros-collector - Select tag:
latest - Click Next
Configure Endpoint
- Click Add New Endpoint
- Enter endpoint name:
collect - Select exposure method:
- CDN - Routes through Bunny CDN (recommended for caching static responses)
- Anycast - Direct routing to container ($2/month for anycast IP)
- Set container port:
8080 - Enable SSL
- Click Next
Deploy
- Review your configuration
- Click Confirm and Create
- Wait for deployment (typically 1-2 minutes)
- Note the endpoint URL (e.g.,
https://walkeros-collector-xxxxx.b-cdn.net)
8. Verify Deployment
Health Check
curl https://YOUR_BUNNY_ENDPOINT/health
Send Test Event
curl -X POST https://YOUR_BUNNY_ENDPOINT/collect \
-H "Content-Type: application/json" \
-d '{
"name": "page view",
"data": {
"title": "Bunny Production Test",
"path": "/"
}
}'
Query BigQuery
bq query --use_legacy_sql=false \
"SELECT name, data, timestamp FROM walkerOS.events ORDER BY timestamp DESC LIMIT 5"
Updating Your Deployment
When you need to update your flow or configuration:
# 1. Make changes and rebuild
docker build -t ghcr.io/YOUR_GITHUB_USERNAME/walkeros-collector:latest .
# 2. Push new image
docker push ghcr.io/YOUR_GITHUB_USERNAME/walkeros-collector:latest
# 3. In Bunny dashboard: Magic Containers → Your App → Redeploy
Next Steps
- Configure event mapping to transform events before sending to BigQuery
- Add more destinations to forward events to multiple services
- Set up Bunny monitoring for your deployment
Cleanup
To remove all created resources:
- Delete the Bunny Magic Container app from the dashboard
- Delete the GHCR image from your GitHub packages
- Clean up BigQuery resources
- Delete local files (
dist/bundle.mjs,sa-bigquery.json,Dockerfile)