Skip to content

Commit ff6f22f

Browse files
hotlongCopilot
andcommitted
fix(deploy): use 'wrangler containers push' instead of docker login
Cloudflare's container registry rejects direct 'docker login registry.cloudflare.com' with 401 (the registry uses temporary credentials issued via the Cloudflare API, not long-lived API tokens). The documented push path is 'wrangler containers push' which obtains a short-lived token and pushes via the local docker daemon. Change: - Build with 'load: true' (image lands in local docker daemon) - Then 'npx wrangler@4 containers push <tag>' authenticates with CLOUDFLARE_API_TOKEN env and pushes from the daemon to the registry. Same change applied to both cloud and objectos jobs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 51e102c commit ff6f22f

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,30 @@ jobs:
125125
- name: Set up Docker Buildx
126126
uses: docker/setup-buildx-action@v3
127127

128-
- name: Log in to Cloudflare container registry
129-
uses: docker/login-action@v3
130-
with:
131-
registry: registry.cloudflare.com
132-
username: ${{ env.ACCOUNT_ID }}
133-
password: ${{ secrets.CLOUDFLARE_API_TOKEN }}
134-
135-
- name: Build + push cloud image
128+
- name: Build cloud image (local)
136129
uses: docker/build-push-action@v6
137130
with:
138131
context: .
139132
file: apps/cloud/Dockerfile
140133
platforms: linux/amd64
141-
push: true
134+
# Load to the local daemon — `wrangler containers push` reads from
135+
# the local daemon and re-pushes with Cloudflare-issued temporary
136+
# registry credentials (the registry rejects plain docker login).
137+
load: true
142138
tags: registry.cloudflare.com/${{ env.ACCOUNT_ID }}/${{ env.IMAGE_NAME }}:${{ env.SHA8 }}
143139
# GitHub Actions cache — drops cloud rebuild from ~20m to ~3-6m
144140
# after the first run.
145141
cache-from: type=gha,scope=cloud
146142
cache-to: type=gha,scope=cloud,mode=max
147143

144+
- name: Push image via wrangler (handles CF registry auth)
145+
env:
146+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
147+
CLOUDFLARE_ACCOUNT_ID: ${{ env.ACCOUNT_ID }}
148+
run: |
149+
npx --yes wrangler@4 containers push \
150+
"registry.cloudflare.com/${ACCOUNT_ID}/${IMAGE_NAME}:${SHA8}"
151+
148152
- name: Pin image tag in wrangler.toml
149153
run: |
150154
set -euo pipefail
@@ -210,24 +214,25 @@ jobs:
210214
- name: Set up Docker Buildx
211215
uses: docker/setup-buildx-action@v3
212216

213-
- name: Log in to Cloudflare container registry
214-
uses: docker/login-action@v3
215-
with:
216-
registry: registry.cloudflare.com
217-
username: ${{ env.ACCOUNT_ID }}
218-
password: ${{ secrets.CLOUDFLARE_API_TOKEN }}
219-
220-
- name: Build + push objectos image
217+
- name: Build objectos image (local)
221218
uses: docker/build-push-action@v6
222219
with:
223220
context: .
224221
file: apps/objectos/Dockerfile
225222
platforms: linux/amd64
226-
push: true
223+
load: true
227224
tags: registry.cloudflare.com/${{ env.ACCOUNT_ID }}/${{ env.IMAGE_NAME }}:${{ env.SHA8 }}
228225
cache-from: type=gha,scope=objectos
229226
cache-to: type=gha,scope=objectos,mode=max
230227

228+
- name: Push image via wrangler (handles CF registry auth)
229+
env:
230+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
231+
CLOUDFLARE_ACCOUNT_ID: ${{ env.ACCOUNT_ID }}
232+
run: |
233+
npx --yes wrangler@4 containers push \
234+
"registry.cloudflare.com/${ACCOUNT_ID}/${IMAGE_NAME}:${SHA8}"
235+
231236
- name: Pin image tag in wrangler.toml
232237
run: |
233238
set -euo pipefail

0 commit comments

Comments
 (0)