Another "assets:precompile" error in rails app deployment

Heading out the door for the evening, but some notes:

  1. remove the node client from Procfile.fly temporarily. Then your server will start. It won’t do what you want, but if you can get your server to start you can use 'flyctl ssh console` to ssh into the machine. From there, you can cd to /app and run the npm commands yourself and debug them. What you want it to get to the point where the node/react server starts. Once you figure out what changes you need to make, adjust your Dockerfile and add back the node client.

  2. You want to configure fly.toml so that port 80 and 443 go to your node app, not your rails app. And you want your rails app to be running on the port where your node app knows how to find it. You can choose any ports for these that you like, including keeping with port 4000 for the node app and 3000 for the rails app.

1 Like

Thanks for the suggestions! I’ll read up on configuring those ports to make sure I know what’s going on there.

I tried removing that client: npm start --prefix client line from the Procfile to get the server to start so that I could use flyctl ssh console.

I still get the lines starting “Shutting down virtual machine,” “Sending signal SIGINT to main child process,” “rails aborted!” etc. around 30 seconds after booting Puma, which is before the health checks pass, so I can’t even get into a console before the server shuts down.

If Rails starts successfully, make sure that internal_port in fly.toml matches the one that Rails is listening on.

Once you have your node app starting, change it to match the port that node is listening on.

I’ve done some more exploration. The right way to handle a rails api server with a create react app client is with a multi-stage docker build: one that compiles the app into static assets that are served, and one that runs the rails application. You can see a working example here: Rails API-only Applications · Fly Docs

Awesome, I’ll dig into that example. I’m still pretty fresh to Docker so I think I’ll need to keep doing some more reading about that too. Thanks again for all of your research and guidance!

You literally can create an empty directory, download the file at the bottom of the page and drop it into the directory with the name Dockerfile, run flyctl launch and flyctl deploy.