How to include/copy folder with Railpack?
dmitry
PROOP

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!

$10 Bounty

49 Replies

dmitry
PROOP

8 months ago

N/A


passos
MODERATOR

8 months ago

Hey, Railpack should automatically include the assets folder, are you getting any errors?


dmitry
PROOP

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.

1386527609927766000


dmitry
PROOP

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 🙂


dmitry
PROOP

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 😄


passos
MODERATOR

8 months ago

are you sure there's nothing under /app?


dmitry
PROOP

8 months ago

There is not

1386530054464606200


dmitry
PROOP

8 months ago

1386530281263075600


dmitry
PROOP

8 months ago

Build logs


dmitry
PROOP

8 months ago

I'd imagine I have to explicitly tell Railpack to copy over extra folders/files I need (along side the binary)?


passos
MODERATOR

8 months ago

that's weird, maybe Railpack does something different for Rust and does not include every asset like other languages.


passos
MODERATOR

8 months ago

and yep, you're right on this one



dmitry
PROOP

8 months ago

Yeah I looked at that.. was trying to find an example for Rust 😄


dmitry
PROOP

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



dmitry
PROOP

8 months ago

Tried searching for Railpack configuration examples using Rust.. but 0 results 😄


dmitry
PROOP

8 months ago

I guess I can fallback to using a Dockerfile 🙂


passos
MODERATOR

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


passos
MODERATOR

8 months ago

{
  "$schema": "https://schema.railpack.com",
  "steps": {
    "build": {
      "inputs": ["...", { "local": true, "include": ["assets"] }]
    }
  }
}

Maybe this should work but I'm not sure…


dmitry
PROOP

8 months ago

Can try it for sure!


passos
MODERATOR

8 months ago

I'll let the team know about your issue, it definitely should be easier to include extra folders on final build.


dmitry
PROOP

8 months ago

Ok we're getting somewhere!


dmitry
PROOP

8 months ago

It copied all the files for some reason tho


dmitry
PROOP

8 months ago

1386533495656157200


dmitry
PROOP

8 months ago

1386533598756077600


dmitry
PROOP

8 months ago

I see this in the build logs


passos
MODERATOR

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" }, "..."]
    }
  }
}

passos
MODERATOR

8 months ago

anyway, i've opened an issue

also if you would like, Nixpacks is an option


dmitry
PROOP

8 months ago

ew Nixpacks no thank you


dmitry
PROOP

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


dmitry
PROOP

8 months ago

All good tho.. I might just go the Dockerfile approach anywho


dmitry
PROOP

8 months ago

I appreciate you debugging and assisting!


passos
MODERATOR

8 months ago

oof


dmitry
PROOP

8 months ago

Yeah idk why it does assets and then does . (all) after lol

1386536131218243600


passos
MODERATOR

8 months ago

maybe removing ... does something as it's a placeholder for previous folder inputs (Railpack's way of layers)


passos
MODERATOR

8 months ago

you may need to include app/bin or may not


passos
MODERATOR

8 months ago

oh seems like there's deployOutputs

{
  "$schema": "https://schema.railpack.com",
  "steps": {
    "build": {
      "deployOutputs": ["assets/*"]
    }
  }
}

dmitry
PROOP

8 months ago

1386540327535382800


dmitry
PROOP

8 months ago

Railway didn't like that syntax 😄


dmitry
PROOP

8 months ago

Got everything working with a Dockerfile.. seems much simpler if you need more fine grained control


dmitry
PROOP

8 months ago

Thanks again for your time!


jr
EMPLOYEE

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"] }
    ]
  }
}

jr
EMPLOYEE

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!)


jr
EMPLOYEE

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)


jr
EMPLOYEE

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


passos
MODERATOR

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 🐐


adam
MODERATOR

8 months ago

!remindme read this later


dmitry
PROOP

8 months ago

Thanks jr for the info regarding Railpack 🙂 Hope this helps others trying to do what I was doing 😄


Loading...