#Package not found when deploying to Fly.io
1 messages · Page 1 of 1 (latest)
What command are you using to deploy?
I'm using the deploy command that runs fly deploy --remote-only
Did you run fly launch first? If so can you post your fly.toml and Dockerfile or share a link to them?
Yes, I ran fly launch first.
This is fly.toml:
# fly.toml file generated for myapp on 2023-01-17T01:16:44+01:00
app = "myapp"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[env]
PORT = "8080"
[experimental]
auto_rollback = true
[[services]]
http_checks = []
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.ports]]
force_https = true
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
And the docker file:
# base node image
FROM node:16-bullseye-slim as base
# Install openssl for Prisma
RUN apt-get update && apt-get install -y openssl
# Install all node_modules, including dev dependencies
FROM base as deps
RUN mkdir /app
WORKDIR /app
ADD package.json package-lock.json ./
RUN npm install --production=false
# Setup production node_modules
FROM base as production-deps
RUN mkdir /app
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
ADD package.json package-lock.json ./
RUN npm prune --production
# Build the app
FROM base as build
ENV NODE_ENV=production
RUN mkdir /app
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
# If we're using Prisma, uncomment to cache the prisma schema
# ADD prisma .
# RUN npx prisma generate
ADD . .
RUN npm run build
# Finally, build the production image with minimal footprint
FROM base
ENV NODE_ENV=production
RUN mkdir /app
WORKDIR /app
COPY --from=production-deps /app/node_modules /app/node_modules
# Uncomment if using Prisma
# COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma
COPY --from=build /app/build /app/build
COPY --from=build /app/public /app/public
ADD . .
CMD ["npm", "run", "start"]
Thanks for your help!
These ones were autogenerated and I did not change anything.
Are you using Prisma?
What's the name of the app? "myapp"?
Did you get any errors on fly launch? If not, it should have asked you if you wanted create a postgres db.
After that it should have asked you if you wanted to deploy.
Is that when you got the Cannot find module 'is-buffer' error?
I'm not using Prisma nor postgres. I tried running fly launch again and now I'm getting this error 🤔 :
Error: Cannot find module 'is-plain-obj'
I'm going to remove the app from Fly and try with a clean build
I said yes to deploy when running launch and I get this is-plain-obj error
I've been able to successfully deploy a new app I created with npx create-remix@latest, so there might be something on my other app that Fly is not happy about. I'll go piece by piece to see where it breaks
I think it has something to do with the react-markdown and axios dependencies (ESM only packages). I also had to remove tiny-invariant
I added this to the remix config: serverDependenciesToBundle: [/react-markdown\/.*/, /axios\/.*/],
Have you run flyctl doctor myapp to see if that provides any insight?
...actually its flyctl doctor -a myapp
or just 'flyctl doctor' if you're currently using the app.
I just ran it and all checks passed
Have you tried installing the missing packages?
There is something going on with my deps. After playing a bit with serverDependenciesToBundle and removing tiny-invariant I've been able to deploy
You might have to use --legacy-peer-deps when installing those packages.
npm i react-markdown --legacy-peer-deps
After adding serverDependenciesToBundle: [/react-markdown\/.*/, /axios\/.*/] it`s working fine (the regex helped me avoiding having to add all deps manually). I might have to do what you mention with tiny-invariant though
Many thanks for your time to help me with that @long river!
I learned some interesting new stuff
Bookmark this page, it will come in handy. https://fly.io/docs/flyctl/help/#available-commands
...it's all the available flyctl commands.