Fly.io deployment help

Hey there,

Has anyone managed to successfully deploy a RedwoodJS app onto Fly.io? I’m not having much luck using the default settings provided when running flyctl launch. When I deploy the app is not accessible so the container restarts over and over:

[error] failed to connect to machine: gave up after 15 attempts (in 9.272853195s)

[error] instance refused connection. is your app listening on 0.0.0.0:8910? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)

Full details are at RedwoodJS deployment is not working - #5 by rubys - Build debugging - Fly.io

Any help is appreciated.

Cheers,
Oliver

Hi @oreid,
I replied to you in your thread on fly.io, let me know if the info helps solve your issue!

I’ll be adding some context to the open issue here #9789 so you can track the progress of the issue as well.

Hope this helps!

1 Like

@oreid – Let us know if you’re able to get everything up and running… We deployed the Conference Badge app via Fly.io. It’s open source, if you want to take a look at any of our settings (like our fly.toml or Dockerfile)

Thanks @tbay06 and @ahaywood. As mentioned in my thread on Fly the issue here has been identified and a work around is available: RedwoodJS deployment is not working - #5 by rubys - Build debugging - Fly.io

I also see that fix(fastify): Prevent duplicate `@fastify/url-data` registration by Josh-Walker-GM · Pull Request #9794 · redwoodjs/redwood · GitHub has been merged and is just awaiting release which will hopefully fix the default generated start script on the fly side.

I am also struggling getting deployed to Fly.IO trying to find a platform to start trying the SSR Streaming and serverful deployments.

I tried from a new create-redwood-app but could not figure out the build errors I was getting so I actually just forked the badge app. I stripped it back down to a basic app just trying to have supabase auth with some of the auth pages working with this repo:

The deploy is a little wonky because I have to make sure it does not overwrite the dockerfile as it’ll try to force it on NODE_VERSION 16.13 as well as remove all the other setup.

It “deploys” but it doesn’t actually have anything showing:
https://flyioishard-young-thunder-8164.fly.dev

FYI, I just successfully deployed a fresh Redwood app (V 8.1.1) on Fly.io. I had a little (actually maybe a lot) of help from Cursor. Here are my Cliff notes…

I followed the instructions at Run a RedwoodJS App · Fly Docs. They are sparse: create a new Redwood app, install the Fly command line tool, and run fly launch. The launch command creates the .fly folder contents and a Dockerfile. The .fly/shart.sh and Dockerfile files needed some adjustments.

I ran fly deploy then fly logs. The first few times I had errors, which I copied and pasted into the Cursor chat window. And, after some iteration, I got it working. The notable fine-tuning included…

Update the Node.js version in the Dockerfile to:
ARG BASE_IMAGE=node:20-alpine

Update the Yarn version in the Dockerfile. I added the following line:
RUN corepack enable && corepack prepare yarn@4.4.0 --activate

Update the Redwood start command in .fly/start.sh. I set it to:
yarn rw serve --web-port ${PORT} --web-host 0.0.0.0 --api-port 8911 --api-host 0.0.0.0

And finally, I did a happy dance when it worked. :man_dancing:

Here is my entire .fly/start.sh file:

#!/bin/sh

set -ex

if [ -n $MIGRATE_ON_BOOT ]; then
  $(dirname $0)/migrate.sh
fi

yarn rw serve --web-port ${PORT} --web-host 0.0.0.0 --api-port 8911 --api-host 0.0.0.0

Here is my entire Dockerfile:

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

RUN mkdir /app
WORKDIR /app

# Enable Corepack and install the correct Yarn version
RUN corepack enable && corepack prepare yarn@4.4.0 --activate

# 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

# Use the correct Yarn version to install dependencies
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"]
2 Likes

I get this warning and nothing renders when I deploy your suggestions.

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
Found these processes inside the machine with open listening sockets:
  PROCESS        | ADDRESSES                             
-----------------*---------------------------------------
  /.fly/hallpass | [fdaa:5:60a9:a7b:325:e55b:e928:2]:22  

I do have this line correctly setup… not sure what’s going on.

yarn rw serve --web-port ${PORT} --web-host 0.0.0.0 --api-port 8911 --api-host 0.0.0.0