- A GitHub account for source code and container registry
- A bunny.net account with Magic Containers enabled
Create the Go API
Create a new directory with the following files:Run locally
Start the development server:Create the Dockerfile
Dockerfile
Build and push to GitHub Container Registry
- GitHub Actions
- Docker CLI
Create Push your code to trigger the workflow:
.github/workflows/build.yml to automatically build and push on every commit to main:.github/workflows/build.yml
If your package is private, set the visibility to Public in GitHub or
configure Magic Containers with registry
credentials.
Deploy to Magic Containers
1
Create a new app
In the bunny.net dashboard, go to Magic Containers and click Add
App. Enter a name and select your deployment option.
2
Add a container
Click Add Container, then configure:
| Field | Value |
|---|---|
| Registry | GitHub Container Registry |
| Image | YOUR_USERNAME/{imageName} |
| Tag | latest |
3
Add an endpoint
Go to the Endpoints tab, click Add New Endpoint, and set the
container port to
80.4
Deploy
Click Add Container, then Next Step, and Confirm and Create.
Test your API
Response
You can add a custom hostname from the Endpoints section in your app settings.
Connect a database
You can connect your app to Bunny Database directly from the dashboard:- Go to Database > [Your Database] > Access
- Click Generate Tokens
- Click Add Secrets to Magic Container App
- Select your app
DB_URL and DB_TOKEN environment variables are now available in your app: