uploading pre-built UI bundle in a 2-service Railway project
Anonymous
FREEOP

25 days ago

I have a React UI making API calls to a backend server. Both the front-end bundle and the backend docker image are built by using github actions. Caddy is installed on my current deployment machine, and serves my front-end bundle for my existing domain.

In moving this arrangement to Railway, I will be using a Railway service for my backend, which can just use my pre-built docker image. But I am not sure about the best way to create a separate Railway service for my front-end.

Is it possible to upload just my pre-built UI bundle (which knows nothing about Caddy) plus my Caddyfile to Railway and have Railway produce the corresponding front-end container including Caddy? If so, how to set that up as a second Railway service?

Or should I build the entire front-end docker image myself for use by Railway, and include in it both Caddy and my front-end bundle?

Many thanks.

Azad

Solved$10 Bounty

Pinned Solution

I don't think Railway would be able to compile an image based from a React project and a Caddyfile. You'd need a custom build configuration to include both, though you can try just by deploying the repository and see what happens.

7 Replies

Railway
BOT

25 days ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway 25 days ago


You'll be creating several services (backend, frontend, etc) for your project. Seeing as it's a React application, I don't think you'll need Caddy, unless the files are being built statically. You can just have the application listen on 0.0.0.0:8080 (8080 for example, but can be any other port).

You can also use a Dockerfile setup as well (https://docs.railway.com/guides/react).


Anonymous
FREEOP

25 days ago

Thank you for your prompt response. I need Caddy to proxy the calls to my backend service. And my React app is being built separately on github by using github actions. I am just not sure how best to make my pre-built front-end files available to the corresponding Railway service.


Sorry for extra questioning but is there a need for proxying the API calls? Railway supports the use of public networking.

Also, I'd recommend setting up a custom Railpack configuration for the build process (Or a Dockerfile).

I'd probably recommend Dockerfile, as you can integrate Caddy directly into the image.


Anonymous
FREEOP

25 days ago

I already have a working configuration to route my API calls to my backend server by using Caddy. It would be simplest for me to continue using the same configuration in my Railway deployment as well.

I was actually hoping there would be a way to let Railway create the front-end image by using my pre-built React code and my Caddyfile only, without the need for Railway to build my React code. Maybe others have experience with clever ways of doing that. So let's keep this track open for a bit.

Many thanks.

Azad


I don't think Railway would be able to compile an image based from a React project and a Caddyfile. You'd need a custom build configuration to include both, though you can try just by deploying the repository and see what happens.


As 0x5b62656e5d said, you need a custom build configuration to do this. And the only way to achieve it is by using a custom Dockerfile setup. You simply copy your pre-built static files into a Caddy container. But it's recommend that you include the frontend building steps in the Dockerfile, otherwise you'd have to build your frontend locally then upload the built static files to Railway everytime, either via github, or by using Railway cli.


Anonymous
FREEOP

25 days ago

Thanks 0x5b62656e5d and darseen for your advice. It is easy enough for me to augment my build of the React code with a final step to create a Caddy docker container to include it. Then deployment to Railway will be straightforward. I will pursue that approach based on your advice.


Status changed to Solved 0x5b62656e5d 5 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...