a year ago
In order to prevent new releases from causing users on-page to encounter page crashes (due to code-split resources no longer being available), I'm trying to persist the build artifacts from Vite after each build.
I use Caddy right now to serve the static Vite build (built with Nixpacks), and it's working great. However, when I attach a volume to /app/frontend/dist (my build location, frontend is a subdirectory of the monorepo), and re-deploy, I get a 404 for all requests made. The volume has data on it, and I can see that it's at 1GB (which seems excessive, the build should be < 20mb).
I'm unable to actually look at the volume and investigate, but I can't see any reason why this wouldn't be working.
10 Replies
a year ago
volumes are not available during build, the assets are placed in dist during build, and then during runtime the volume is mounted there, the volume being empty means dist is now empty.
you would need to run the build during runtime, or more preferably (imo), use a cdn for assets.
Hm, thanks. A CDN is a little tricky because we proxy requests through Railway to serve on the same origin, which helps make PR environment deployments work.
a year ago
something that serves the assets externally (either externally from railway or externally from the railway service) is best since services with a volume will have downtime between deploys
Got it. We currently use CloudFlare pages to do this, but the big downside is that means we can't make it available in PR environments. Is there some way to pass the URL generated from a Github action to a Railway PR environment?
a year ago
we don't have any way to natively inject variables into pr envs
Gotcha, so it wouldn't be possible to serve a static application CDN and be able to use Railway PR environments?
a year ago
i mean its all about implementation, im sure theres some way to do it, its just i havent done it myself
Personally I would just use a proper CI that supports caching and artifacts to do the builds
a year ago
!s
Status changed to Solved brody • about 1 year ago