Hi everyone,
I’ve recently setup a new Remix project using the Blues-stack (GitHub - remix-run/blues-stack: The Remix Stack for deploying to Fly with PostgreSQL, authentication, testing, linting, formatting, etc. ). However, consistently the project is failing on the docker build step with a 404 error. This is a copy of the docker output:
#19 3.306 Building Remix app in production mode...
#19 3.771 Built in 464ms
#19 4.060
#19 4.060 > build:server
#19 4.060 > esbuild --platform=node --format=cjs ./server.ts --outdir=build
#19 4.060
#19 4.070
#19 4.070 build/server.js 3.2kb
#19 4.070
#19 4.070 ⚡ Done in 2ms
#19 DONE 4.1s
#20 [stage-4 3/6] COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma
#20 DONE 0.2s
#21 [stage-4 4/6] COPY --from=build /myapp/build /myapp/build
#21 DONE 0.0s
#22 [stage-4 5/6] COPY --from=build /myapp/public /myapp/public
#22 DONE 0.0s
#23 [stage-4 6/6] ADD . .
#23 DONE 0.0s
#24 exporting to image
#24 exporting layers
#24 exporting layers 7.5s done
#24 ...
#25 [auth] sharing credentials for registry.fly.io
#25 DONE 0.0s
#24 exporting to image
#24 exporting manifest sha256:555d69678b1111c7d39670e6497734a0b7233b421ef5a9730d41395eb00572b2 done
#24 exporting config sha256:271e7ab0d8eb33f55a70d4e4584f41b69032788c90ae6[323](https://github.com/victorias/worth/runs/5683958837?check_suite_focus=true#step:8:323)0dae105f5a3c419a done
#24 pushing layers
#24 pushing layers 0.1s done
#24 ERROR: unexpected status: 404 Not Found
------
> exporting to image:
------
error: failed to solve: unexpected status: 404 Not Found
Error: buildx failed with: error: failed to solve: unexpected status: 404 Not Found
The github action workflow step that is being run looks like this:
build:
name: 🐳 Build
# only build/deploy main branch on pushes
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
- name: ⬇️ Checkout repo
uses: actions/checkout@v3
- name: 👀 Read app name
uses: SebRollen/toml-action@v1.0.0
id: app_name
with:
file: "fly.toml"
field: "app"
- name: 🐳 Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Setup cache
- name: ⚡️ Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: 🔑 Fly Registry Auth
uses: docker/login-action@v1
with:
registry: registry.fly.io
username: x
password: ${{ secrets.FLY_API_TOKEN }}
- name: 🐳 Docker build
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}
build-args: |
COMMIT_SHA=${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
# This ugly bit is necessary if you don't want your cache to grow forever
# till it hits GitHub's limit of 5GB.
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: 🚚 Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
I’ve been advised that possibly my Github FLY_API_TOKEN secret is incorrect, but I’ve already tried updating that and it hasn’t resolved the issue. Any help is much appreciated!
kurt
March 29, 2022, 12:48am
2
Wow that’s a really strange error.
Are you comfortable inviting me to the GitHub project for this so I can poke at it? My GitHub username is mrkurt
.
Thank you so much! I’ve sent you an invitation from
https://github.com/victorias/worth
kurt
March 29, 2022, 1:06am
4
I think the app name in fly.toml
wasn’t correct. Can you check and see if the <name>-4865
was intentional in there?
That 404 is coming from our registry because it’s trying to push to an app that doesn’t exist.
1 Like
kurt
March 29, 2022, 1:10am
5
Oh it also looks like the FLY_API_TOKEN
secret isn’t set properly for the GitHub repository. You can get that value by running flyctl auth token
locally, or generate one here: Sign In · Fly
Hi @kurt ,
I’ve followed many advices found here and there:
Downgrade buildx to 0.9.1
Set provenance
to false
Reset the FLY_API_TOKEN
I’m still facing the same issue:
#24 [auth] sharing credentials for registry.fly.io
#24 DONE 0.0s
#23 exporting to image
#23 pushing layers 0.5s done
#23 ERROR: failed to push registry.fly.io/h*****:staging-97e362506edacc363e2651138778c8519a75eb8f: unexpected status: 404 Not Found
------
> exporting to image:
------
WARNING: local cache import at /tmp/.buildx-cache not found due to err: could not read /tmp/.buildx-cache/index.json: open /tmp/.buildx-cache/index.json: no such file or directory
ERROR: failed to solve: failed to push registry.fly.io/h*****:staging-97e362506edacc363e2651138778c8519a75eb8f: unexpected status: 404 Not Found
Error: buildx failed with: ERROR: failed to solve: failed to push registry.fly.io/h*****:staging-97e362506edacc363e2651138778c8519a75eb8f: unexpected status: 404 Not Found
Here is the build part of my deploy.yml:
build:
name: 🐳 Build
# only build/deploy main branch on pushes
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') && github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
- name: ⬇️ Checkout repo
uses: actions/checkout@v3
- name: 👀 Read app name
uses: SebRollen/toml-action@v1.0.2
id: app_name
with:
file: "fly.toml"
field: "app"
- name: 🐳 Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: v0.9.1
# Setup cache
- name: ⚡️ Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: 🔑 Fly Registry Auth
uses: docker/login-action@v2
with:
registry: registry.fly.io
username: x
password: ${{ secrets.FLY_API_TOKEN }}
- name: 🐳 Docker build
uses: docker/build-push-action@v4
with:
context: .
push: true
provenance: false
tags: registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}
build-args: |
COMMIT_SHA=${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
# This ugly bit is necessary if you don't want your cache to grow forever
# till it hits GitHub's limit of 5GB.
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: 🚚 Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
I would greatly appreciate your help
Ok something was not clear for me, hope this could help the next confused guy.
I’ve created two apps: <myapp>-main
and <myapp>-staging
.
I was pushing on the staging branch.
But because I’m using --app ${{ steps.app_name.outputs.value }}-staging
and --app ${{ steps.app_name.outputs.value }}-main
in the deploy phase, I named my app <myapp>
in the fly.toml, not corresponding to an existing app.
TL;DR: even if you’re pushing to a different app via a different branch, you must ensure the app name you use in fly.toml exists.
- name: 🐳 Docker build
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}
build-args: |
COMMIT_SHA=${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
# This ugly bit is necessary if you don't want your cache to grow forever
# till it hits GitHub's limit of 5GB.
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: 🚚 Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
deploy:
name: 🚀 Deploy
runs-on: ubuntu-latest
# needs: [lint, typecheck, vitest, cypress, build]
needs: [lint, typecheck, vitest, build]
# only build/deploy main branch on pushes
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') && github.event_name == 'push' }}
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
- name: ⬇️ Checkout repo
uses: actions/checkout@v3
- name: 👀 Read app name
uses: SebRollen/toml-action@v1.0.0
id: app_name
with:
file: "fly.toml"
field: "app"
- name: 🚀 Deploy Staging
if: ${{ github.ref == 'refs/heads/staging' }}
uses: superfly/flyctl-actions@1.3
with:
args: "deploy --app ${{ steps.app_name.outputs.value }}-staging --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}"
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
- name: 🚀 Deploy Production
if: ${{ github.ref == 'refs/heads/main' }}
uses: superfly/flyctl-actions@1.3
with:
args: "deploy --app ${{ steps.app_name.outputs.value }}-main --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}"
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}