diff --git a/magic-containers/bunny-container-registry.mdx b/magic-containers/bunny-container-registry.mdx index a63a5835..9efc69a5 100644 --- a/magic-containers/bunny-container-registry.mdx +++ b/magic-containers/bunny-container-registry.mdx @@ -10,7 +10,7 @@ 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 (`/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 (`/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. 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`. @@ -18,7 +18,7 @@ Magic Containers only supports images built for the **linux/amd64** architecture ## 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). `bunny registry` is **experimental** and may change in future releases. @@ -26,7 +26,7 @@ The recommended way to push images is with the [bunny CLI](/cli). It handles aut - + If you haven't already, [install the CLI](/cli/installation) and authenticate: @@ -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. @@ -56,11 +56,13 @@ The image now appears in the Magic Containers image list. Select it when you [de -## 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 + + + Without flags, `push` derives the repository and tag from the image name. Override either with flags: @@ -68,7 +70,11 @@ Without flags, `push` derives the repository and tag from the image name. Overri bunny registry push my-app:dev --repository my-app --tag v1 ``` -### List repositories and tags + + + + +Verify the push by listing what's on the registry: ```bash # List repositories (alias: ls) @@ -80,11 +86,17 @@ bunny registry tags my-app `list` and `tags` talk to the registry directly and don't require Docker. + + + + ## 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. + + -### Log in to the registry + Authenticate with `token` as the username and your [API key](/account/api-keys) as the password: @@ -92,7 +104,9 @@ Authenticate with `token` as the username and your [API key](/account/api-keys) docker login registry.bunny.net --username token ``` -### Tag your image + + + Tag the image with the registry host and your account ID. Replace `my-app` with the name of your image and `` with your account ID: @@ -101,10 +115,12 @@ docker tag my-app registry.bunny.net//my-app:latest ``` -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. -### Push the image + + + ```bash docker push registry.bunny.net//my-app:latest @@ -112,10 +128,60 @@ docker push registry.bunny.net//my-app:latest Once pushed, the image appears in the Magic Containers image list, where you can select it to deploy. + + + + +## 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. + + + + + +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 +``` + + + + + +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//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//my-app:latest +``` + + + + + +```bash +container image push registry.bunny.net//my-app:latest +``` + +Once pushed, the image appears in the Magic Containers image list, where you can select it to deploy. + + + + + ## 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: diff --git a/magic-containers/deploy-with-github-actions.mdx b/magic-containers/deploy-with-github-actions.mdx index e54b4a16..10c10b31 100644 --- a/magic-containers/deploy-with-github-actions.mdx +++ b/magic-containers/deploy-with-github-actions.mdx @@ -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 }}" -``` + + + ```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 }}" + ``` + + + + The [Bunny Container Registry](/magic-containers/bunny-container-registry) is in **Closed Preview**. See [Product Release Stages](/product-release-stages) for details. + + + 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 }}" + ``` + + ## Inputs