Payload-CMS and Railway

xdnlorPRO

9 months ago

hey there, I've created a new postgres db on railway, installed payload-cms locally and used the DATABASEPUBLICURI 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

0 Replies

xdnlorPRO

9 months ago

c6f6ed4c-e840-4f0f-b7ad-a7e86b392112


xdnlorPRO

9 months ago

okay, i created a empty yarn.lock file and things moved along, but now it's just crashing


9 months ago

have you checked your logs?


xdnlorPRO

9 months ago

if createad two variables in the empty service that I've linked to Payload now.
PAYLOADSECRET with the Payload secret from my local env file and DATABASEURI 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?


9 months ago

you would set your variables here -


xdnlorPRO

9 months ago

that's where I added them


9 months ago

your database variable would be incorrect, its needs to be the full url


xdnlorPRO

9 months ago

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


9 months ago

are you sure payload is listening on host 0.0.0.0?


xdnlorPRO

9 months ago

I'm probably just doing something very obvious wrong, first time dipping my toes into headless cms territory and depolyment etc.


xdnlorPRO

9 months ago

thanks, trying to edit the config


xdnlorPRO

9 months ago

success!!


xdnlorPRO

9 months ago

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?


9 months ago

truthfully, an empty yarn.lock file should have given you more issues, so im not sure what went wrong / right there


xdnlorPRO

9 months ago

yeah I was suprise that just worked. beginners luck I guess


9 months ago

well I'm glad it worked out!