Failure to deploy RedwoodJS app because fly can't find the schema.prisma file

I’m trying to deploy an existing RedwoodJS app with Fly.io.

I have verified that I can create a new redwood app and deploy via fly launch but when I fly launch from my other app, I see this failure.

It probably goes without saying I do have a schema.prisma file defined and the redwood app is pretty boilerplate here. Nothing out of the ordinary.

The key failure is here:

Skipping database and Prisma client generation, no `schema.prisma` file found: `/app/api/db/schema.prisma`

Rest of the output here:

 => CANCELED [api_build 2/2] RUN yarn rw build api                                                                                                                                                     9.8s
 => ERROR [web_build 2/2] RUN yarn rw build web                                                                                                                                                        9.5s
------
 > [web_build 2/2] RUN yarn rw build web:
#0 9.296 ❯ Generating Prisma Client...
#0 9.297 Skipping database and Prisma client generation, no `schema.prisma` file found: `/app/api/db/schema.prisma`
#0 9.300 ✖ Generating Prisma Client... [FAILED: Command failed with ERR_INVALID_ARG_TYPE:
#0 9.300 The "file" argument must be of type string. Received undefined]
#0 9.301
#0 9.313 ┌ Error ───────────────────────────────────────────────────────────────────────┐│                                                                              ││   TypeError [ERR_INVALID_ARG_TYPE]: Command failed with                      ││   ERR_INVALID_ARG_TYPE:                                                      ││   The "file" argument must be of type string. Received undefined
││   at new NodeError (node:internal/errors:371:5)                              ││   at validateString (node:internal/validators:119:11)                        ││   at normalizeSpawnArguments (node:child_process:503:3)                      ││   at Object.spawn (node:child_process:691:13)                                ││   at execa (/app/node_modules/execa/index.js:83:26)                          ││   at _Task.task [as taskFn]                                                  ││   (/app/node_modules/@redwoodjs/cli/dist/commands/buildHandler.js:73:33)     ││   at _Task.run (/app/node_modules/listr2/dist/index.cjs:2049:35)             ││                                                                              ││                                                                              ││                                                                              ││   Need help?                                                                 ││   - Not sure about something or need advice? Reach out on our Forum          ││   (https://community.redwoodjs.com/)                                       ││   - Think you've found a bug? Open an issue on our GitHub                    ││   (https://github.com/redwoodjs/redwood)                                   ││   - Here's your unique error reference to quote:                             ││   'f2c0c856-66de-4cca-95c5-5aaba149fad7'                                     ││                                                                              │└──────────────────────────────────────────────────────────────────────────────┘
------
Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c yarn rw build web]: exit code: 1

Can you post your Dockerfile? It is possible that this step is being run before the COPY statement that loads your entire application (normally something like COPY . .) is run.

Here it is. All of the defaults - I didn’t change anything.

ARG BASE_IMAGE=node:16.13.0-alpine
FROM ${BASE_IMAGE} as base

RUN mkdir /app
WORKDIR /app

# Required for building the api and web distributions
ENV NODE_ENV development

FROM base as dependencies

COPY .yarn .yarn
COPY .yarnrc.yml .yarnrc.yml
COPY package.json package.json
COPY web/package.json web/package.json
COPY api/package.json api/package.json
COPY yarn.lock yarn.lock

RUN --mount=type=cache,target=/root/.yarn/berry/cache \
    --mount=type=cache,target=/root/.cache yarn install --immutable

COPY redwood.toml .
COPY graphql.config.js .

FROM dependencies as web_build

COPY web web
RUN yarn rw build web

FROM dependencies as api_build

COPY api api
RUN yarn rw build api

FROM dependencies

ENV NODE_ENV production

COPY --from=web_build /app/web/dist /app/web/dist
COPY --from=api_build /app/api /app/api
COPY --from=api_build /app/node_modules/.prisma /app/node_modules/.prisma

COPY .fly .fly

ENTRYPOINT ["sh"]
CMD [".fly/start.sh"]

The redwood team is working on a new dockerfile. You can get a sneak peek at the result here: https://github.com/redwoodjs/ticket-badge-app/blob/staging/Dockerfile

But for now, and with the Dockerfile that you have, you may need to add some COPY statements. The first block of COPY statements copy all of the files needed to install dependencies. Basically the yarn install command will only be run if any of these files change.

A total of three files are copied before yarn rw build web is run. It looks like with your project you need to add prisma to this list.

Thank you for the help @rubys .
The deployment is successful for me but I the site is unreachable. I think because of this warning during deployment.

WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.
You can fix this by configuring your app to listen on the following addresses:
  - 0.0.0.0:8910 for job

Do you have any idea how to resolve this for a RedwoodJS app? I’ve verified my Redwood.toml/fly.toml/Dockerfile are consistent with the ticket-badge-app you linked above.

Aha! Figured it out. Just needed to add:

host = "0.0.0.0"

to both the [api] and [web] sections of the redwood.toml file.

1 Like

I’m also trying to get a Fly.io deployment of a RedwoodJS project running. I’m running into the same issue that you had @natemac with 0.0.0.0:8910 not being reachable. Unfortunately, adding host to [api] and [web] and running flyctl deploy is not resolving the issue. Any other ideas? I added the fly config via flyctl launch.

1 Like

Still getting this 0.0.0.0:8910 with the latest Dockerfile from redwood and my redwood.toml includes the host = ‘0.0.0.0’ for both api and web.