You know, I’m a bit new using fly.io, yesterday I uploaded my portfolio website developed with Next.js into an fly.io’s domain to public it into the web, but I’ve been having a problem with it.
So, the page is published into the web … I guess, here’s the link: portfolio-nicolas-zapata.fly.dev. What happened? Well, the tab loads eternally, and the page finally doesn’t load.
So, I did the flyctl status and then it launched this status:
App
Name = portfolio-nicolas-zapata
Owner = personal
Hostname = portfolio-nicolas-zapata.fly.dev
Image = portfolio-nicolas-zapata:deployment-01J6BD082EMVZ2JMW001TZH29Y
Machines
PROCESS ID VERSION REGION STATE ROLE CHECKS LAST UPDATED
app 56830241add918 2 ewr stopped 2024-08-28T16:11:04Z
app 6833e41a730528 2 ewr stopped 2024-08-28T16:11:28Z
app 7842741b49ed28 2 bog stopped 2024-08-28T16:10:07Z
app 7843ed3c23e778 2 ewr stopped 2024-08-28T16:11:53Z
app d89d521a4dd618 2 ewr starting 2024-08-28T16:12:14Z
app d8d9945a230728 2 bog stopped 2024-08-28T16:10:33Z
So, I don’t know what happened, if is normal which the state shows it as “stopped”, and what’s the steps to fix this strange issue. What do you think, guys?
For a personal portfolio site, you probably don’t need to scale up that many instances… I would start w/ 1 region and 1 machine (unless you’re Mr. Popular).
# syntax = docker/dockerfile:1
# Adjust NODE_VERSION as desired
ARG NODE_VERSION=18.18.0
FROM node:${NODE_VERSION}-slim as base
LABEL fly_launch_runtime="Next.js"
# Next.js app lives here
WORKDIR /app
# Set production environment
ENV NODE_ENV="production"
# Throw-away build stage to reduce size of final image
FROM base as build
# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3
# Install node modules
COPY --link package-lock.json package.json ./
RUN npm ci
# Copy application code
COPY --link . .
# Final stage for app image
FROM base
# Copy built application
COPY --from=build /app /app
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "node", "index.js" ]
Well, I saw a lot of info messages, It has 1 error which could be the error that you mean.
2024-08-28T19:39:45.607 proxy[7842741b49ed28] bog [error] [PM05] failed to connect to machine: gave up after 15 attempts (in 22.108188495s)
Also, I saw few info messages referring that the module can’t be finded, I’m so confused:
2024-08-28T19:39:33.596 app[7842741b49ed28] bog [info] INFO [fly api proxy] listening at /.fly/api
2024-08-28T19:39:33.601 app[7842741b49ed28] bog [info] 2024/08/28 19:39:33 INFO SSH listening listen_address=[fdaa:9:f995:a7b:273:80ea:e215:2]:22 dns_server=[fdaa::3]:53
2024-08-28T19:39:33.621 runner[7842741b49ed28] bog [info] Machine started in 778ms
2024-08-28T19:39:33.622 proxy[7842741b49ed28] bog [info] machine started in 782.083769ms
2024-08-28T19:39:33.759 app[7842741b49ed28] bog [info] node:internal/modules/cjs/loader:1080
2024-08-28T19:39:33.759 app[7842741b49ed28] bog [info] throw err;
2024-08-28T19:39:33.759 app[7842741b49ed28] bog [info] ^
2024-08-28T19:39:33.759 app[7842741b49ed28] bog [info] Error: Cannot find module '/app/index.js'
2024-08-28T19:39:33.759 app[7842741b49ed28] bog [info] at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
2024-08-28T19:39:33.759 app[7842741b49ed28] bog [info] at Module._load (node:internal/modules/cjs/loader:922:27)
2024-08-28T19:39:33.759 app[7842741b49ed28] bog [info] at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
2024-08-28T19:39:33.759 app[7842741b49ed28] bog [info] at node:internal/main/run_main_module:23:47 {
2024-08-28T19:39:33.759 app[7842741b49ed28] bog [info] code: 'MODULE_NOT_FOUND',
2024-08-28T19:39:33.759 app[7842741b49ed28] bog [info] requireStack: []
2024-08-28T19:39:33.759 app[7842741b49ed28] bog [info] }
2024-08-28T19:39:33.759 app[7842741b49ed28] bog [info] Node.js v18.18.0