Custom node app not starting
-
Values coming from an
.env
file added iin the DockerfileDB = '${CLOUDRON_MONGODB_HOST}://${CLOUDRON_MONGODB_USERNAME}:${CLOUDRON_MONGODB_PASSWORD}@${CLOUDRON_MONGODB_URL}/{CLOUDRON_MONGODB_DATABASE}' BASE_URL = '${CLOUDRON_APP_DOMAIN}' PORT = ${CLOUDRON_MONGODB_PORT} COOKIE_KEY = 4c5h3sve45yte55rgae984hvs4780gtsRH5ygrs54r5Hr4adRSjgg66y8634 SIGNUPS = on NODE_OPTIONS = --max_old_space_size=460 HTTPS = false APPDIRECTORY = 'voip'
-
The app's code reads the port from the
.env
config file.
But doesn't seem to like what I wrote (above)app.get('/get-base-url', function(req, res) { res.status(200).json({url: process.env.BASE_URL.trim()}); }); server.listen(process.env.PORT)
-
@timconsidine For PORT the ' characters are missing? Is that ok?
-
@timconsidine said in Custom node app not starting:
PORT = ${CLOUDRON_MONGODB_PORT}
Is this correct? Why is the app listening on MONGODB's port?
-
@timconsidine said in Custom node app not starting:
Sep 06 13:14:40 at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
Sep 06 13:14:40code: 'EROFS',
Sep 06 13:14:40errno: -30,
Sep 06 13:14:40syscall: 'listen',
Sep 06 13:14:40address: '${CLOUDRON_MONGODB_PORT}',
Sep 06 13:14:40port: -1Per the above error, it looks like the app is trying to listen literally on the string
${CLOUDRON_MONGODB_PORT}
. i.e there is no environment variable expansion happenning. BTW, you might be wrongly assuming that you can even use environment variable in that .env file. -
@Kubernetes said in Custom node app not starting:
For PORT the ' characters are missing? Is that ok?
I assumed as numeric value they are not needed, but it's sure worth a try.
Thank you -
@girish said in Custom node app not starting:
Is this correct? Why is the app listening on MONGODB's port?
Hmmm, very good point.
I think I just assumed it was Mongo's port, but looking at the original repo, maybe it is not. Probably entirely my error. -
@girish said in Custom node app not starting:
BTW, you might be wrongly assuming that you can even use environment variable in that .env file.
Err, yes I was assuming and didn't start to think how they would be interpolated ! Thank you.
So what is best practice in this case ?
Construct the.env
file and populate values in the Dockerfile ? -
We generate env files usually in start.sh like:
cat > /app/data/env << EOF # Add custom environment variables in this file NEXT_PUBLIC_APP_NAME="${CLOUDRON_APP_DOMAIN}" NEXT_PUBLIC_COMPANY_NAME="${CLOUDRON_APP_DOMAIN}" EOF
-
Ah !
Yes, I guess Dockerfile doesn't know these when the image is built.
Apologies, brain definitely slow.
Not sure if I should blame the heat or old age !
Thank you @girishAnd thank you @Kubernetes
Exactly the pointers I needed.
-
Yay !
Those corrections got me past the initial issue.
Some other problem now that I will investigate before sharing a repo in case useful to someone. -
Update :
Custom app now installed and working - thanks again @girish and @Kubernetes
Will make a repo and share link -
I have now created a repo for my custom package : https://git.cloudron.io/timconsidine/smsvoip-cloudron/
This packages a "desktop SMS" app which allows you to send/receive SMS on a virtual number (not your phone's number).
It is also useful for "fake" registrations for things like WhatsApp etc.