Payload-CMS and Railway
hey there, I've created a new postgres db on railway, installed payload-cms locally and used the DATABASE_PUBLIC_URI string to connect from the blank install to my db. which worked yay
but I've now for the first time tried to use the Railway CLI and tried to get that local empty Payload-CMS project into the same Project/enviorment that my postgres db is on Railway. created an empty service online first, an then tried railway link -> picked the project - > picked the empty service and then railway up. and got "Build failed: : Failed to build an image. If this error persists, please contact Railway support."
wondering what I'm doing wrong here.
Log says:
Dockerfile:19
-------------------
17 | WORKDIR /home/node/app
18 | COPY package*.json ./
19 | >>> COPY yarn.lock ./
20 |
21 | RUN yarn install --production
-------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/yarn.lock": not found
xed out the number since I#ve no clue what I should share or not hehe
13 Replies
Project ID:
c6f6ed4c-e840-4f0f-b7ad-a7e86b392112
c6f6ed4c-e840-4f0f-b7ad-a7e86b392112
okay, i created a empty yarn.lock file and things moved along, but now it's just crashing
have you checked your logs?
if createad two variables in the empty service that I've linked to Payload now.
PAYLOAD_SECRET with the Payload secret from my local env file and DATABASE_URI where I used the internal link to the Postgres db, that can also be added as DATABASE_URL.
I get the following error: [23:00:44] ERROR (payload): Error: cannot connect to Postgres. Details: getaddrinfo ENOTFOUND base
Just so I get this right. when pushing a project to RAILWAY I have to manually add the info from the env file as variables for the container, or are they still in there, but I can overwrite and add variables to the env file if I set the same variable to a different value on the Railway service container?
you would set your variables here - https://docs.railway.app/overview/the-basics#service-variables
that's where I added them
your database variable would be incorrect, its needs to be the full url
thanks Brody, I've tried that before, but now that I did it again, the container is running. minor victory 🙂
If I try to access the admin panel with https://payload.up.railway.app/admin I get a "Application failed to respond" error
are you sure payload is listening on host
0.0.0.0
?I'm probably just doing something very obvious wrong, first time dipping my toes into headless cms territory and depolyment etc.
thanks, trying to edit the config
success!!
thanks brody, may I just ask why I had to add the empty yarn.lock file, if there was a package.json present? does that have something to do with the way railway is building the docker image or is that something related to payload cms?
truthfully, an empty yarn.lock file should have given you more issues, so im not sure what went wrong / right there
yeah I was suprise that just worked. beginners luck I guess
well I'm glad it worked out!