Skip to content
90 changes: 78 additions & 12 deletions magic-containers/bunny-container-registry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ Bunny Container Registry is in **Preview**. Usage is temporarily free during the

Bunny Container Registry is a private, OCI-compliant container registry built into bunny.net. Push images from your machine or CI pipeline and they immediately show up in the Magic Containers image list, ready to deploy. No external registry or credential setup required.

The registry is available at `registry.bunny.net`. Repositories are private to your account and namespaced by your account ID (`<account-id>/my-app`). The [bunny CLI](/cli) manages this namespace for you, so you only need your account ID when [pushing with Docker directly](#pushing-with-docker).
The registry is available at `registry.bunny.net`. Repositories are private to your account and namespaced by your account ID (`<account-id>/my-app`). The [bunny.net CLI](/cli) manages this namespace for you, so you only need your account ID when pushing with [Docker](#pushing-with-docker) or [Apple Container](#pushing-with-apple-container) directly.

<Info>
Magic Containers only supports images built for the **linux/amd64** architecture. When building your container image, ensure you target this platform using `--platform linux/amd64`.
</Info>

## Quickstart

The recommended way to push images is with the [bunny CLI](/cli). It handles authentication and the account namespace for you, so no registry configuration is needed.
The recommended way to push images is with the [bunny.net CLI](/cli).

<Note>
`bunny registry` is **experimental** and may change in future releases.
</Note>

<Steps>

<Step title="Install the bunny CLI and log in">
<Step title="Install the bunny.net CLI and log in">

If you haven't already, [install the CLI](/cli/installation) and authenticate:

Expand All @@ -44,7 +44,7 @@ Push a local Docker image by name. The CLI tags it for the registry and pushes i
bunny registry push my-app:latest
```

`push` uses Docker to read the local image, so Docker must be installed and the image must exist locally.
`push` shells out to the Docker CLI, so Docker must be installed and the image must exist in Docker's image store. Images built with Apple Container aren't visible to Docker; push those with [`container image push`](#pushing-with-apple-container) instead.

</Step>

Expand All @@ -56,19 +56,25 @@ The image now appears in the Magic Containers image list. Select it when you [de

</Steps>

## Using the bunny CLI
## Using the bunny.net CLI

The [`bunny registry`](/cli/commands/registry) command pushes images and lists repositories and tags on the registry. Unlike Docker, you don't need to tag images with the registry host or your account ID: the CLI adds and hides the account namespace automatically, so you always work with the bare repository name.

### Push to an explicit repository and tag
<Steps>

<Step title="Push to an explicit repository and tag">

Without flags, `push` derives the repository and tag from the image name. Override either with flags:

```bash
bunny registry push my-app:dev --repository my-app --tag v1
```

### List repositories and tags
</Step>

<Step title="List repositories and tags">

Verify the push by listing what's on the registry:

```bash
# List repositories (alias: ls)
Expand All @@ -80,19 +86,27 @@ bunny registry tags my-app

`list` and `tags` talk to the registry directly and don't require Docker.

</Step>

</Steps>

## Pushing with Docker

If you can't use the bunny CLI, for example in a CI pipeline where only Docker is available, you can push images with Docker directly. Unlike the CLI, you handle authentication and the account namespace yourself.
If you can't use the bunny.net CLI, for example in a CI pipeline where only Docker is available, you can push images with Docker directly. Unlike the CLI, you handle authentication and the account namespace yourself.

<Steps>

### Log in to the registry
<Step title="Log in to the registry">

Authenticate with `token` as the username and your [API key](/account/api-keys) as the password:

```bash
docker login registry.bunny.net --username token
```

### Tag your image
</Step>

<Step title="Tag your image">

Tag the image with the registry host and your account ID. Replace `my-app` with the name of your image and `<account-id>` with your account ID:

Expand All @@ -101,21 +115,73 @@ docker tag my-app registry.bunny.net/<account-id>/my-app:latest
```

<Tip>
Need your account ID? Run [`bunny whoami`](/cli/commands/auth#bunny-whoami), which prints it. You can also find it in the dashboard: go to [Image Registries](https://dash.bunny.net/magic-containers/image-registries) and click **How to Push Images** to see these Docker commands with your account ID already filled in.
Run [`bunny whoami`](/cli/commands/auth#bunny-whoami) to get your account ID. You can also find it in the dashboard: go to [Image Registries](https://dash.bunny.net/magic-containers/image-registries) and click **How to Push Images** to see these Docker commands with your account ID already filled in.
</Tip>

### Push the image
</Step>

<Step title="Push the image">

```bash
docker push registry.bunny.net/<account-id>/my-app:latest
```

Once pushed, the image appears in the Magic Containers image list, where you can select it to deploy.

</Step>

</Steps>

## Pushing with Apple Container

[Apple Container](https://github.com/apple/container) is Apple's open-source container tool for macOS. Its registry commands work with the Bunny Container Registry the same way Docker's do: you handle authentication and the account namespace yourself.

<Steps>

<Step title="Log in to the registry">

Authenticate with `token` as the username and your [API key](/account/api-keys) as the password:

```bash
container registry login registry.bunny.net --username token
```

</Step>

<Step title="Build for linux/amd64">

On Apple silicon, Apple Container builds images for `arm64` by default, which Magic Containers can't run. Pass `--arch amd64` when building:

```bash
container build --arch amd64 --tag registry.bunny.net/<account-id>/my-app:latest .
```

If you already have an image built for `amd64`, tag it with the registry host and your account ID instead:

```bash
container image tag my-app registry.bunny.net/<account-id>/my-app:latest
```

</Step>

<Step title="Push the image">

```bash
container image push registry.bunny.net/<account-id>/my-app:latest
```

Once pushed, the image appears in the Magic Containers image list, where you can select it to deploy.

</Step>

</Steps>

## Deploying pushed images

Images pushed to the Bunny Container Registry appear automatically in the image list when you [deploy](/magic-containers/deploy) or [update](/magic-containers/update) a Magic Containers app. Select the repository and tag to deploy; no registry credentials need to be configured.

To automate the whole flow, so every push to your repository builds an image, pushes it to the registry, and rolls it out, see [Deploy with GitHub Actions](/magic-containers/deploy-with-github-actions).

## Limits

The following limits apply to each account:
Expand Down
122 changes: 84 additions & 38 deletions magic-containers/deploy-with-github-actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,95 @@ Automate your deployments by integrating Magic Containers with GitHub Actions. W

- An application already deployed on the Magic Containers platform
- A GitHub repository containing a Dockerfile or valid build context
- Container registry credentials (use `GITHUB_TOKEN` for GitHub Container Registry, or personal access tokens for DockerHub)
- Container registry credentials (`GITHUB_TOKEN` for GitHub Container Registry, your bunny.net API key for the [Bunny Container Registry](/magic-containers/bunny-container-registry), or a personal access token for DockerHub)

## Quickstart

Add a step to your GitHub Actions workflow with the following inputs: `app_id`, `api_key`, `container`, and `image_tag`. This triggers a rolling update whenever a new image is built and pushed.

```yml
name: Update container image when pushing to main

on:
push:
branches:
- "main"

jobs:
build:
name: Build and deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: docker login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: docker build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}

- name: Update container image on Magic Containers
uses: BunnyWay/actions/container-update-image@main
with:
app_id: ${{ vars.APP_ID }}
api_key: ${{ secrets.BUNNYNET_API_KEY }}
container: app
image_tag: "${{ github.sha }}"
```
<Tabs>
<Tab title="GitHub Container Registry">
```yml
name: Update container image when pushing to main

on:
push:
branches:
- "main"

jobs:
build:
name: Build and deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: docker login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: docker build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}

- name: Update container image on Magic Containers
uses: BunnyWay/actions/container-update-image@main
with:
app_id: ${{ vars.APP_ID }}
api_key: ${{ secrets.BUNNYNET_API_KEY }}
container: app
image_tag: "${{ github.sha }}"
```
</Tab>
<Tab title="Bunny Container Registry">
<Note>
The [Bunny Container Registry](/magic-containers/bunny-container-registry) is in **Closed Preview**. See [Product Release Stages](/product-release-stages) for details.
</Note>

Push with the [bunny.net CLI](/cli): it authenticates the push and namespaces the image under your account, so the workflow needs no registry login step and no account ID variable. The same API key secret authenticates both the registry push and the Magic Containers update.

```yml
name: Update container image when pushing to main

on:
push:
branches:
- "main"

jobs:
build:
name: Build and deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install the bunny.net CLI
run: npm install -g @bunny.net/cli

- name: docker build
run: docker build --platform linux/amd64 --tag my-app:${{ github.sha }} .

- name: Push to the Bunny Container Registry
run: bunny registry push my-app:${{ github.sha }}
env:
BUNNYNET_API_KEY: ${{ secrets.BUNNYNET_API_KEY }}

- name: Update container image on Magic Containers
uses: BunnyWay/actions/container-update-image@main
with:
app_id: ${{ vars.APP_ID }}
api_key: ${{ secrets.BUNNYNET_API_KEY }}
container: app
image_tag: "${{ github.sha }}"
```
</Tab>
</Tabs>

## Inputs

Expand Down