Deploy Remix with apps v2

Hello everyone,

I’m currently facing an issue while attempting to deploy a clean and untouched remix blues stack (GitHub - remix-run/blues-stack: The Remix Stack for deploying to Fly with PostgreSQL, authentication, testing, linting, formatting, etc.) to fly with apps v2. I’ve been unsuccessful so far and could really use some guidance. Specifically, I’m having trouble deploying both the main and staging environments, and I’m unsure about what might be causing the problem. The Github action seems to get stuck at the “deploy staging” stage, continuously spinning without any progress.

Any insights or suggestions would be greatly appreciated. Thank you in advance!

I plan to be looking into that next week. The first issue is that the format of fly.toml changed. It should look something like this:

app = "..."
primary_region = "..."

[mounts]
source = "data"
destination = "/data"

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true

Keep the app name from your existing fly.toml. Pick a region near you from the following page: Regions · Fly Docs

That may be enough, but probably will just get you to the next problem. If you do try it out, please report back and we can work through it together.

Here is my full fly.toml and the error I’m getting while building with Github Actions.

app = "appname"
primary_region = "ams"
kill_signal = "SIGINT"
kill_timeout = 5
processes = [ ]

[env]
PORT = "8080"
METRICS_PORT = "8081"

[metrics]
port = 8_081
path = "/metrics"

[deploy]
release_command = "npx prisma migrate deploy"

[experimental]
allowed_public_ports = [ ]
auto_rollback = true

[[services]]
internal_port = 8_080
processes = [ "app" ]
protocol = "tcp"
script_checks = [ ]

  [services.concurrency]
  hard_limit = 25
  soft_limit = 20
  type = "connections"

  [[services.ports]]
  handlers = [ "http" ]
  port = 80
  force_https = true

  [[services.ports]]
  handlers = [ "tls", "http" ]
  port = 443

  [[services.tcp_checks]]
  grace_period = "1s"
  interval = "15s"
  restart_limit = 0
  timeout = "2s"

  [[services.http_checks]]
  interval = "10s"
  grace_period = "5s"
  method = "get"
  path = "/healthcheck"
  protocol = "http"
  timeout = "2s"
  tls_skip_verify = false
  headers = { }
==> Verifying app config
Validating /github/workspace/fly.toml
Platform: machines
✓ Configuration is valid
--> Verified app config
==> Building image
Searching for image 'registry.fly.io/todays-design:dev-35b8dce462428377465e7d53b868cb9cf500ba32' remotely...
image found: img_8y6w4zyyk20v7rn3

Watch your app at https://fly.io/apps/todays-design-staging/monitoring

Running todays-design-staging release_command: npx prisma migrate deploy
  Created release_command machine 6e82d922f29ee8
  Waiting for 6e82d922f29ee8 to have state: started
  Machine 6e82d922f29ee8 has state: started
  Waiting for 6e82d922f29ee8 to have state: destroyed
  Machine 6e82d922f29ee8 has state: destroyed
  Waiting for 6e82d922f29ee8 to get exit event
Error release_command failed running on machine 6e82d922f29ee8 with exit code 137.
Check its logs: here's the last 100 lines below, or run 'fly logs -i 6e82d922f29ee8':
  Pulling container image registry.fly.io/todays-design:dev-35b8dce462428377465e7d53b868cb9cf500ba32
  Successfully prepared image registry.fly.io/todays-design:dev-35b8dce462428377465e7d53b868cb9cf500ba32 (7.097209534s)
  Configuring firecracker
  Starting init (commit: 0ae2eef)...
  Preparing to run: `docker-entrypoint.sh npx prisma migrate deploy` as root
  2023/05/14 18:37:24 listening on [fdaa:0:5eeb:a7b:141:f758:f8d8:2]:22 (DNS: [fdaa::3]:53)
  npm WARN exec The following package was not found and will be installed: prisma@4.14.0
  [    8.130909] Out of memory: Killed process 551 (node) total-vm:11113768kB, anon-rss:104008kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:1172kB oom_score_adj:0
  Killed
  npm notice
  npm notice New major version of npm available! 8.19.4 -> 9.6.6
  npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.6.6>
  npm notice Run `npm install -g npm@9.6.6` to update!
  npm notice
  Starting clean up.
  [   10.124306] reboot: Restarting system
  machine restart policy set to 'no', not restarting
Error: release command failed - aborting deployment. error release_command machine 6e82d922f29ee8 exited with non-zero status of 137
2023-05-13T16:41:25.345 app[148ed420a71d38] ams [info] > start

2023-05-13T16:41:25.345 app[148ed420a71d38] ams [info] > cross-env NODE_ENV=production node ./build/server.js

2023-05-13T16:41:26.681 app[148ed420a71d38] ams [info] 🔌 setting up prisma client to ams.todays-design-staging-db.flycast:5432

2023-05-13T16:41:27.707 app[148ed420a71d38] ams [info] ✅ app ready: http://localhost:8080

2023-05-13T16:41:27.707 app[148ed420a71d38] ams [info] ✅ metrics ready: http://localhost:8081/metrics

2023-05-13T16:41:27.708 app[148ed420a71d38] ams [info] (node:537) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.

2023-05-13T16:41:27.708 app[148ed420a71d38] ams [info] Please migrate your code to use AWS SDK for JavaScript (v3).

2023-05-13T16:41:27.708 app[148ed420a71d38] ams [info] For more information, check the migration guide at https://a.co/7PzMCcy

2023-05-13T16:41:27.708 app[148ed420a71d38] ams [info] (Use `node --trace-warnings ...` to show where the warning was created)

2023-05-13T16:41:27.805 app[148ed420a71d38] ams [info] HEAD / 200 - - 40.927 ms

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] healthcheck ❌ {

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] error: PrismaClientInitializationError:

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] Invalid `prisma.user.count()` invocation:

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] Can't reach database server at `ams.todays-design-staging-db.flycast`:`5432`

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] Please make sure your database server is running at `ams.todays-design-staging-db.flycast`:`5432`.

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] at Zr.handleRequestError (/myapp/node_modules/@prisma/client/runtime/library.js:171:6688)

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] at Zr.handleAndLogRequestError (/myapp/node_modules/@prisma/client/runtime/library.js:171:5948)

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] at /myapp/node_modules/@prisma/client/runtime/library.js:174:3087

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] at /myapp/node_modules/@prisma/client/runtime/library.js:174:3268

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] at t._executeRequest (/myapp/node_modules/@prisma/client/runtime/library.js:174:10726)

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] at t._request (/myapp/node_modules/@prisma/client/runtime/library.js:174:10455)

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] at async Promise.all (index 0)

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] at loader24 (/myapp/build/index.js:8528:12)

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] at Object.callRouteLoaderRR (/myapp/build/server.js:39556:20)

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] at callLoaderOrAction (/myapp/build/server.js:38674:20) {

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] clientVersion: '4.11.0',

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] errorCode: undefined

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] }

2023-05-13T16:41:27.891 app[148ed420a71d38] ams [info] }

2023-05-13T16:41:27.896 app[148ed420a71d38] ams [info] /myapp/node_modules/@prisma/client/runtime/library.js:101

2023-05-13T16:41:27.896 app[148ed420a71d38] ams [info] You may have to run ${Gt.default.greenBright("prisma generate")} for your changes to take effect.`,this.config.clientVersion);return r}parseEngineResponse(r){if(!r)throw new W("Response from the Engine was empty",{clientVersion:this.config.clientVersion});try{return JSON.parse(r)}catch{throw new W("Unable to JSON.parse response from engine",{clientVersion:this.config.clientVersion})}}convertDatasources(r){let n=Object.create(null);for(let{name:i,url:o}of r)n[i]=o;return n}async loadEngine(){if(!this.engine){this.QueryEngineConstructor||(this.library=await this.libraryLoader.loadLibrary(),this.QueryEngineConstructor=this.library.QueryEngine);try{let r=new WeakRef(this);this.engine=new this.QueryEngineConstructor({datamodel:this.datamodel,env:process.env,logQueries:this.config.logQueries??!1,ignoreEnvVarErrors:!0,datasourceOverrides:this.datasourceOverrides,logLevel:this.logLevel,configDir:this.config.cwd,engineProtocol:this.engineProtocol},n=>{r.deref()?.logger(n)}),Nl++}catch(r){let n=r,i=this.parseInitError(n.message);throw typeof i=="string"?n:new G(i.message,this.config.clientVersion,i.error_code)}}}logger(r){let n=this.parseEngineResponse(r);if(!!n){if("span"in n){this.config.tracingConfig.enabled===!0&&co(n);return}n.level=n?.level.toLowerCase()??"unknown",Vd(n)?this.logEmitter.emit("query",{timestamp:new Date,query:n.query,params:n.params,duration:Number(n.duration_ms),target:n.module_path}):Qd(n)?this.loggerRustPanic=new ce(this.getErrorMessageWithLink(`${n.message}: ${n.reason} in ${n.file}:${n.line}:${n.column}`),this.config.clientVersion):this.logEmitter.emit(n.level,{timestamp:new Date,message:n.message,target:n.module_path})}}getErrorMessageWithLink(r){return Ya({platform:this.platform,title:r,version:this.config.clientVersion,engineVersion:this.versionInfo?.commit,database:this.config.activeProvider,query:this.lastQuery})}parseInitError(r){try{return JSON.parse(r)}catch{}return r}parseRequestError(r){try{return JSON.parse(r)}catch{}return r}on(r,n){r==="beforeExit"?this.beforeExitListener=n:this.logEmitter.on(r,n)}async start(){if(await this.libraryInstantiationPromise,await this.libraryStoppingPromise,this.libraryStartingPromise)return je(`library already starting, this.libraryStarted: ${this.libraryStarted}`),this.libraryStartingPromise;if(this.libraryStarted)return;let r=l(async()=>{je("library starting");try{let i={traceparent:Ne({tracingConfig:this.config.tracingConfig})};await this.engine?.connect(JSON.stringify(i)),this.libraryStarted=!0,je("library started")}catch(i){let o=this.parseInitError(i.message);throw typeof o=="string"?i:new G(o.message,this.config.clientVersion,o.error_code)}finally{this.libraryStartingPromise=void 0}},"startFn"),n={name:"connect",enabled:this.config.tracingConfig.enabled};return this.libraryStartingPromise=fe(n,r),this.libraryStartingPromise}async stop(){if(await this.libraryStartingPromise,await this.executingQueryPromise,this.libraryStoppingPromise)return je("library is already stopping"),this.libraryStoppingPromise;if(!this.libraryStarted)return;let r=l(async()=>{await new Promise(o=>setTimeout(o,5)),je("library stopping");let i={traceparent:Ne({tracingConfig:this.config.tracingConfig})};await this.engine?.disconnect(JSON.stringify(i)),this.libraryStarted=!1,this.libraryStoppingPromise=void 0,je("library stopped")},"stopFn"),n={name:"disconnect",enabled:this.config.tracingConfig.enabled};return this.libraryStoppingPromise=fe(n,r),this.libraryStoppingPromise}async getDmmf(){await this.start();let r=Ne({tracingConfig:this.config.tracingConfig}),n=await this.engine.dmmf(JSON.stringify({traceparent:r}));return fe({name:"parseDmmf",enabled:this.config.tracingConfig.enabled,internal:!0},()=>JSON.parse(n))}version(){return this.versionInfo=this.library?.version(),this.versionInfo?.version??"unknown"}debugPanic(r){return this.library?.debugPanic(r)}async request(r,{traceparent:n,interactiveTransaction:i}){je(`sending request, this.libraryStarted: ${this.libraryStarted}`);let o=JSON.stringify({traceparent:n}),s=JSON.stringify(r);try{await this.start(),this.executingQueryPromise=this.engine?.query(s,o,i?.id),this.lastQuery=s;let a=this.parseEngineResponse(await this.executingQueryPromise);if(a.errors)throw a.errors.length===1?this.buildQueryError(a.errors[0]):new W(JSON.stringify(a.errors),{clientVersion:this.config.clientVersion});if(this.loggerRustPanic)throw this.loggerRustPanic;return{data:a,elapsed:0}}catch(a){if(a instanceof G)throw a;if(a.code==="GenericFailure"&&a.message?.startsWith("PANIC:"))throw new ce(this.getErrorMessageWithLink(a.message),this.config.clientVersion);let u=this.parseRequestError(a.message);throw typeof u=="string"?a:new W(`${u.message}

2023-05-13T16:41:27.896 app[148ed420a71d38] ams [info] ^

2023-05-13T16:41:27.896 app[148ed420a71d38] ams [info] Error: Can't reach database server at `ams.todays-design-staging-db.flycast`:`5432`

2023-05-13T16:41:27.896 app[148ed420a71d38] ams [info] Please make sure your database server is running at `ams.todays-design-staging-db.flycast`:`5432`.

2023-05-13T16:41:27.896 app[148ed420a71d38] ams [info] at startFn (/myapp/node_modules/@prisma/client/runtime/library.js:101:2598)

2023-05-13T16:41:27.912 app[148ed420a71d38] ams [info] npm notice

2023-05-13T16:41:27.912 app[148ed420a71d38] ams [info] npm notice New major version of npm available! 8.19.4 -> 9.6.6

2023-05-13T16:41:27.912 app[148ed420a71d38] ams [info] npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.6.6>

2023-05-13T16:41:27.912 app[148ed420a71d38] ams [info] npm notice Run `npm install -g npm@9.6.6` to update!

2023-05-13T16:41:27.913 app[148ed420a71d38] ams [info] npm notice

2023-05-13T16:41:28.749 app[148ed420a71d38] ams [info] Starting clean up.

2023-05-13T16:41:29.750 app[148ed420a71d38] ams [info] [ 5.108824] reboot: Restarting system

2023-05-13T16:41:30.670 runner[148ed420a71d38] ams [info] machine has reached its max restart count (10)

Machines

Alright, I managed to resolve the issue and now it’s working perfectly.

Here’s what I did: I didn’t make many changes, but I stumbled upon this helpful issue on Github (Fly.io -> Error: Can't reach database server · Issue #182 · remix-run/blues-stack · GitHub), which redirected me back to the Fly community (https://community.fly.io/t/my-postgres-database-is-down-for-no-reason/12664/3). As mentioned, I commented out the line:

// databaseUrl.host = `${FLY_REGION}.${databaseUrl.host}`;

and that did the trick.

Furthermore, I noticed that there is already a pull request (fix: don't add `FLY_REGION` prefix when using recent `flyctl` version by benwaffle · Pull Request #187 · remix-run/blues-stack · GitHub) addressing the same issue.

I hope this information helps others who might encounter a similar problem.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.