Fly launch created docker-entrypoint.js - target is not defined

I have a node app and ran fly launch. It created a docker-entrypoint.js file and includes a line to a variable that isn’t defined. What is the target supposed to be?

Fly logs:

file:///app/docker-entrypoint.js:10
  const newDb = target && !fs.existsSync(target)
                ^
ReferenceError: target is not defined
    at file:///app/docker-entrypoint.js:10:17

Section from docker-entrypoint.js:

// If running the web server then migrate existing database
if (process.argv.slice(-3).join(' ') === 'npm run start') {
  const newDb = target && !fs.existsSync(target)
  if (newDb && process.env.BUCKET_NAME) {
    await exec(`litestream restore -config litestream.yml -if-replica-exists ${target}`)
  }
  await exec('npx prisma migrate deploy')
}

That looks like a bug, and I’d like to fix it. By any chance, are you using prisma, and can you share the datasource portion of your schame.prisma file?

A correct docker-entrypoint.js would look something like this:

There will be a lot of variation on this theme, bases on things like if your app is "type": "module" or not.

Yes I am using prisma and here is the datasource section:

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

My app is “type”: “module” as well.

Based on the example file that you showed I switched my schema.prisma file to use a hardcoded value instead of an environment variable then recreated the fly app. This generated the right source and target.

Cool.

I’ve created a PR with a fix, including a test case:

In your Dockerfile, you would put:

And in your docker-entrypoint.js:

1 Like

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