I want to enquire , data persisted during 1 deployement can be used by 2nd deployment.
him8127
HOBBYOP

7 months ago

I am storing certain .json and it is scheduled to be stored once in a day when load is less. But every new commit in GitHub will trigger auto-build process. I want that, .json stored shall be accessible to all deployments rather than being deleted in each build process. Is there any way to achieve on this platform. I am on hobby plan.

I am newbie on railway, so please help me out!!

Thanks!!

Solved$10 Bounty

Pinned Solution

smolpaw
HOBBY

7 months ago

What you need is called volumes. They are persistent data storage that keep state between deployments.
What currently is happening is your app creates a file at /app/data.json. When a new deployment comes, a new container is spun up and previous container along with any data is deleted.
If you want to persist the data.json file then you need to mount the volume at /app so that when a new container is spun up, the same volume is mounted that contains any data written at /app location by previous containers.

2 Replies

testuser123
PRO

7 months ago

Can you please elaborate? What type of data from deployment 1 you need for deployment 2 that you're not getting?

I mean, you can always push the JSON to a database (PostgreSQL, Redis) or a service like S3, Cloudflare R2, Supabase Storage, etc.


smolpaw
HOBBY

7 months ago

What you need is called volumes. They are persistent data storage that keep state between deployments.
What currently is happening is your app creates a file at /app/data.json. When a new deployment comes, a new container is spun up and previous container along with any data is deleted.
If you want to persist the data.json file then you need to mount the volume at /app so that when a new container is spun up, the same volume is mounted that contains any data written at /app location by previous containers.


Status changed to Solved chandrika 7 months ago


Loading...