Friction when setting up a Node service on fly.io

Hello. I am a first-time user of fly.io. I ran into a number of issues when setting up my first app to be deployed to fly.io, which I’d like to share.

My hope is that fly.io engineers will implement some fixes for the following issues so that future customers will have an easier time getting started.

1. Autogenerated Dockerfile for Node project references package that doesn’t exist

Below is the Dockerfile that “fly” autogenerates when building a Node app:


Notice that it tries to install “python-is-python3” with apt-get. However that package doesn’t actually exist. I changed it to install “python3” instead to workaround.

2. Autogenerated fly.toml uses inconsistent port numbers internally

Below is the Dockerfile that “fly.toml” autogenerates when building a Node app:


Notice that http_service.internal_port and env.PORT are using different values.

3. “fly” command (sometimes) hangs if you forget to login

Repro Steps:

  • Open a new Terminal window on macOS.
  • Run the command “fly status”

Expected Results:

  • Error message appears saying that I need to login.

Actual Results:

  • Nothing happens. Process hangs. I must close the Terminal window to stop the “fly” command.
2 Likes

That’s strange. First, let me quote a line of code: https://github.com/fly-apps/dockerfile-node/blob/5cde98d938f38714fcfa025300b7687906ef07db/gdf.js#L312-L315

 // How to install python (switched from buster to bullseye)
  get python() {
    return parseInt(this.nodeVersion.split('.')[0]) > 16 ? 'python-is-python3' : 'python'
  }

You should only be seeing “python-is-python3” for Node > 16. Looking at your dockerfile, it appears that you are using Node 16.16.

What is going on here is that Debian changed package names from buster to bullseye. Node 16 dockerhub default images are built on buster. Node 17 to 19 default images are built using bullseye. Node 20 default images are built using bookworm.

Can you tell me more about your app? As an example, if I go into an empty directory and type npx express-generator and then fly launch, my fly.toml doesn’t have an [env] section.

I’m not seeing that here, and have to leave that to others to address. I wrote the code that fly launch uses to generate Dockerfiles for Node apps and can help with any problems in Dockerfiles and fly.toml files.

1 Like

Thanks for the quick response!

Hmm. My local version of Node (outside of any Docker containers) is also 16.16 so you’d expect the “python” package to be used based on the above code, which is correct. :man_shrugging:t2:

Sure. @rubys could you send me your GitHub username? I’ll invite you to the affected repository.

@rubys, I’ve added you to the affected repository. The commit that’s probably the most interesting to focus on is here in the commit list:

Can I ask what flyctl version you are running?

Running the latest flyctl (or running GitHub - fly-apps/dockerfile-node: Dockerfile generator for Node.js directly) produces the Dockerfile (and fly.toml) I expect.

Here’s my flyctl version:

$ flyctl version
Update available 0.1.47 -> 0.1.51.
Run "flyctl version upgrade" to upgrade.
flyctl v0.1.47 darwin/amd64 Commit: c39ca26fffe52f54832e94c8767995d2ba3a41c3-dirty BuildDate: 2023-07-03T17:00:20Z

If I remember correctly I installed it using Homebrew.

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