8 months ago
Hi there! I'm deploying a Rust (Axum) API to Railway. I'm using zero configuration for Railpack at the moment (it just works).
I'm trying to serve static assets from an assets folder in my application via Rust (check the screenshot).
How do I get Railpack to include this assets folder into my final app?
Any assistance would be greatly appreciated. Thank you!
49 Replies
8 months ago
N/A
8 months ago
Hey, Railpack should automatically include the assets folder, are you getting any errors?
8 months ago
Hey thanks for your reply. No errors during build!
Does the assets folder need to be in the /src directory or is it fine being outside? Railpack knows to include the assets folder by default? I SSH'd into my Railway instance and I only see the built Rust binary.

8 months ago
Also to be clear.. I don't need the assets folder to be included during build time.. I just need it to exist in my instance.. so my Rust API can serve static assets from that folder 🙂
8 months ago
So I imagined I prob need to tell Railpack to like copy the folder or something after the build step? Not sure 😄
8 months ago
are you sure there's nothing under /app?
8 months ago
There is not

8 months ago

8 months ago
Build logs
8 months ago
I'd imagine I have to explicitly tell Railpack to copy over extra folders/files I need (along side the binary)?
8 months ago
that's weird, maybe Railpack does something different for Rust and does not include every asset like other languages.
8 months ago
and yep, you're right on this one
8 months ago
8 months ago
Yeah I looked at that.. was trying to find an example for Rust 😄
8 months ago
Was also trying to find the base config that Railway uses.. and then I could just modify that.. but haven't found that yet either
8 months ago
Tried searching for Railpack configuration examples using Rust.. but 0 results 😄
8 months ago
I guess I can fallback to using a Dockerfile 🙂
8 months ago
I kinda had the same problem as you but on the install step
https://discord.com/channels/713503345364697088/1352038617534693507
But yeah I guess a Dockerfile would be better, I'm not too familiar with Railpack's config file
8 months ago
{
"$schema": "https://schema.railpack.com",
"steps": {
"build": {
"inputs": ["...", { "local": true, "include": ["assets"] }]
}
}
}Maybe this should work but I'm not sure…
8 months ago
Can try it for sure!
8 months ago
I'll let the team know about your issue, it definitely should be easier to include extra folders on final build.
8 months ago
Ok we're getting somewhere!
8 months ago
It copied all the files for some reason tho
8 months ago

8 months ago

8 months ago
I see this in the build logs
8 months ago
Being honest I'm lost just as you're <:kekw:788259314607325204>
maybe try this one?
{
"$schema": "https://schema.railpack.com",
"steps": {
"install": {
"commands": [{"src": "assets", "dest": "assets" }, "..."]
}
}
}8 months ago
anyway, i've opened an issue
also if you would like, Nixpacks is an option
8 months ago
ew Nixpacks no thank you
8 months ago
This seems to have the same result for some reason. Just copied all the files in my project into the /app directory
8 months ago
All good tho.. I might just go the Dockerfile approach anywho
8 months ago
I appreciate you debugging and assisting!
8 months ago
oof
8 months ago
Yeah idk why it does assets and then does . (all) after lol

8 months ago
maybe removing ... does something as it's a placeholder for previous folder inputs (Railpack's way of layers)
8 months ago
you may need to include app/bin or may not
8 months ago
oh seems like there's deployOutputs
{
"$schema": "https://schema.railpack.com",
"steps": {
"build": {
"deployOutputs": ["assets/*"]
}
}
}8 months ago

8 months ago
Railway didn't like that syntax 😄
8 months ago
Got everything working with a Dockerfile.. seems much simpler if you need more fine grained control
8 months ago
Thanks again for your time!
8 months ago
hello I can shed some light on what is happening with these configs. Each Railpack step is like a separate section in a multi-stage dockerfile and has explicit inputs and outputs. An input to one step can be the output of a previous step. This is works well when Railpack is automatically constructing the build, but can get confusing when trying to extend it. Currently, when you manually specify a step in a railpack.json file, that entire steps contents will be added to the final output. Basically it will include too much rather than too little (this is why you see the full contents of your repo in the final image even if you are just adding assets to the build step). I'll be working on improving this in the coming week because I agree it is confusing.
The simplest way to include another directory in the final image is to update the deploy inputs. This is how the final image is put together.
{
"$schema": "https://schema.railpack.com",
"deploy": {
"inputs": [
// Automatic inputs from the Rust provider
"...",
// Specifically include the assets directory from the local source
{ "local": true, "include": ["assets"] }
// Alternatively, you could include the assets directory from the build step
{ "step": "build", "include": ["assets"] }
]
}
}8 months ago
Update the steps if you want to run additional custom commands. Update the deploy inputs if you want to add additional things to the final image (you are specifying all the different layers in a really modular way. actually really cool!)
8 months ago
That said, I am just going to update the Rust provider so that all the local code is include. This is the default with the other providers and should offer maximum compatibility (and for a negligble increase in image size)
8 months ago
Also a custom Dockerfile will always give you the most control and Railway will continue to support that. Railpack is meant as a way of deploying with zero config and we are still expanding compatability
8 months ago
Oh, there are inputs inside deploy. I thought it wasn't part of the steps properties and that there was no way of specifying the inputs and outputs. Anyway, thanks jr again! truly the 🐐
8 months ago
!remindme read this later
8 months ago
Thanks jr for the info regarding Railpack 🙂 Hope this helps others trying to do what I was doing 😄