I’ve been running Umami on fly with no issues through several versions, initially based on suggestions from this post.
With Umami’s recent upgrade to v2.6.0, I ran into Cannot find module
issues on app startup. I created an issue at Umami’s github repo, but I’m posting here, because no other users seem to be having the same issue.
fly.toml
:
app = <app name>
primary_region = "lax"
kill_signal = "SIGINT"
kill_timeout = 5
[experimental]
auto_rollback = true
[build.args]
DATABASE_TYPE = "postgresql"
[deploy]
release_command = "yarn check-db"
[[services]]
protocol = "tcp"
internal_port = 3000
processes = ["app"]
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 1
[[services.ports]]
port = 80
handlers = ["http"]
force_https = true
[[services.ports]]
port = 443
handlers = ["tls", "http"]
[services.concurrency]
type = "connections"
hard_limit = 25
soft_limit = 20
[[services.tcp_checks]]
interval = "15s"
timeout = "2s"
grace_period = "1s"
restart_limit = 0
fly.toml
sits in the root directory of Umami’s source, and uses Umami’s Dockerfile, with one line added (as suggested in comment 5 of the discussion linked above):
# Production image, copy all the files and run next
FROM node:18-alpine AS runner
+ RUN apk --update add postgresql-client
With the fly.toml
quoted above, I get this:
yarn run v1.22.19
$ node scripts/check-db.js
node:internal/modules/cjs/loader:1080
throw err;
^
Error: Cannot find module '@prisma/client'
Require stack:
- /app/scripts/check-db.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:121:18)
at Object.<anonymous> (/app/scripts/check-db.js:3:26)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/app/scripts/check-db.js' ]
}
Node.js v18.17.1
error Command failed with exit code 1.
If I use
[deploy]
release_command = "yarn start-docker"
to match the CMD
in Umami’s Dockerfile, I get
yarn run v1.22.19
$ npm-run-all check-db update-tracker start-server
node:internal/modules/cjs/loader:446
throw err;
^
Error: Cannot find module '/app/node_modules/semver/index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:438:19)
at Module._findPath (node:internal/modules/cjs/loader:680:18)
at Module._resolveFilename (node:internal/modules/cjs/loader:1063:27)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:121:18)
at Object.<anonymous> (/app/node_modules/cross-spawn/lib/parse.js:8:16)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32) {
code: 'MODULE_NOT_FOUND',
path: '/app/node_modules/semver/package.json',
requestPath: 'semver'
}
Node.js v18.17.1
error Command failed with exit code 1.
Same thing happens when I omit release_command
altogether.
I have also applied HOSTNAME
to the build arguments as per this Umami issue related to Fly, but I think it hasn’t proved relevant yet for me because the app fails to start in the first place.
Any suggestions for troubleshooting would be very appreciated!