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

**URL:** <https://community.fly.io/t/fly-launch-created-docker-entrypoint-js-target-is-not-defined/24065>\
**Category:** JavaScript\
**Tags:** sqlite, login-only\
**Created:** [February 27, 2025, 5:39pm UTC](https://community.fly.io/t/fly-launch-created-docker-entrypoint-js-target-is-not-defined/24065 "2025-02-27T17:39:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Overman](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Steven\_Overman](https://community.fly.io/u/Steven_Overman)\
**Post date:** [February 27, 2025, 5:39pm UTC](https://community.fly.io/t/fly-launch-created-docker-entrypoint-js-target-is-not-defined/24065/1 "2025-02-27T17:39:58Z")

</div>

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:

```auto
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:

```auto
// 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')
}

```

---

<div class="post-metadata">

**Author:** ![rubys](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/rubys/32/16907_2.png) [@rubys](https://community.fly.io/u/rubys)\
**Post date:** [February 27, 2025, 6:01pm UTC](https://community.fly.io/t/fly-launch-created-docker-entrypoint-js-target-is-not-defined/24065/2 "2025-02-27T18:01:19Z")

</div>

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:

> <https://github.com/fly-apps/dockerfile-node/blob/main/test/base/litestream/docker-entrypoint.js>

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

---

<div class="post-metadata">

**Author:** ![Steven\_Overman](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Steven\_Overman](https://community.fly.io/u/Steven_Overman)\
**Post date:** [February 27, 2025, 6:08pm UTC](https://community.fly.io/t/fly-launch-created-docker-entrypoint-js-target-is-not-defined/24065/3 "2025-02-27T18:08:43Z")

</div>

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

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

```

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

---

<div class="post-metadata">

**Author:** ![Steven\_Overman](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Steven\_Overman](https://community.fly.io/u/Steven_Overman)\
**Post date:** [February 27, 2025, 7:44pm UTC](https://community.fly.io/t/fly-launch-created-docker-entrypoint-js-target-is-not-defined/24065/4 "2025-02-27T19:44:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rubys](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/rubys/32/16907_2.png) [@rubys](https://community.fly.io/u/rubys)\
**Post date:** [February 27, 2025, 8:08pm UTC](https://community.fly.io/t/fly-launch-created-docker-entrypoint-js-target-is-not-defined/24065/5 "2025-02-27T20:08:31Z")

</div>

Cool.

I’ve created a [PR](https://github.com/fly-apps/dockerfile-node/pull/138) with a fix, including a test case:

In your Dockerfile, you would put:

> <https://github.com/fly-apps/dockerfile-node/blob/2dfb0f0758c5eede35cf1c9343c86d9efdc12f45/test/base/litestream-url/Dockerfile#L60-L60>

And in your docker-entrypoint.js:

> <https://github.com/fly-apps/dockerfile-node/blob/2dfb0f0758c5eede35cf1c9343c86d9efdc12f45/test/base/litestream-url/docker-entrypoint.js#L10-L11>

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/fly1/original/3X/6/e/6e8955d00cb218e186ebbe3a6ab06fefdce15290.svg) [@system](https://community.fly.io/u/system)\
**Post date:** [March 6, 2025, 8:44pm UTC](https://community.fly.io/t/fly-launch-created-docker-entrypoint-js-target-is-not-defined/24065/8 "2025-03-06T20:44:48Z")

</div>

Closed on March 6, 2025, 8:44pm UTC

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