I’m gonna list my questions and issues on the same topic because I think they are all related
-
Am I correct to assume there are only two options for places my build stage can accour? Locally (wherever
flyctl deploy
is called) and remote (on anyfly.io
machine my app owns)? -
When I run a build with
--remote-only
. It means the build will run, for sure, on my fly.io instace AND will have access to both.flycast
and.internal
from apps on the same organization. And if it’s run--local-only
it will run, for sure, on whatever environment theflyctl deploy
was called, and will not have access to.flycast
and.internal
urls. Is this correct? -
Environment variables are not available on build steps by default. And the only way to make them available, is to include them on the
flyctl deploy
command throught the--build-secret DATABASE_URL=${{DATABASE_URL}}
argument. Is this correct?
These are the three thing I assumed to be correct when building my deploy pipeline. Unfortunately, there are two thing wrong on my deploys:
- I use the nextJs server proxy to route requests to my backend. Unfortunately, nextJs requests are failing the
.flycast
address to my backend server, as it can be observed on the following logs:
2024-10-25 10:34:55.009 @diet-it/web:start: hostname: 'diet-it-backend.flycast'
2024-10-25 10:34:55.009 @diet-it/web:start: syscall: 'getaddrinfo',
2024-10-25 10:34:55.009 @diet-it/web:start: code: 'ENOTFOUND',
2024-10-25 10:34:55.009 @diet-it/web:start: errno: -3007,
2024-10-25 10:34:55.009 @diet-it/web:start: at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) {
2024-10-25 10:34:55.009 @diet-it/web:start: Error: getaddrinfo ENOTFOUND diet-it-backend.flycast
2024-10-25 10:34:55.002 @diet-it/web:start: }
Here are two addresses to my backend server:
https://diet-it-backend.fly.dev/
https://backend.dietit.co/
2. I doesn’t matter what I try. My Fly Deploy
github actions never work. They either fail because they don’t have access to the DATABASE_URL (required in my build step) or they do a false positive deploy on github, but the deploy never shows up on my dashboard and the server never gets updates.
Here’re my Fly Deploy
github actions:
# /.github/workflows/fly-deploy-web.yml
name: Fly Deploy
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy @diet-it/web
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy . --remote-only -a diet-it-web --config ./apps/web/fly.toml --dockerfile ./apps/web/Dockerfile --build-secret DATABASE_URL=${{ secrets.DATABASE_URL }} / DATABASE_URL=https://diet-it-backend.flycast/
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_WEB }}
# /.github/workflows/fly-deploy-backend.yml
name: Fly Deploy
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy @diet-it/backend
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy . --remote-only -a diet-it-backend --config ./apps/backend/fly.toml --dockerfile ./apps/backend/Dockerfile
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_BACKEND }}
Has anyone gone through something like this? Thank you in advance!