How to include/copy folder with Railpack?

a year 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

a year ago

N/A


a year ago

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


a year 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.

1386527609927766107


a year 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 🙂


a year ago

So I imagined I prob need to tell Railpack to like copy the folder or something after the build step? Not sure 😄


a year ago

are you sure there's nothing under /app?


a year ago

There is not

1386530054464606280


a year ago

1386530281263075478


a year ago

Build logs


a year ago

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


a year ago

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


a year ago

and yep, you're right on this one



a year ago

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


a year 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



a year ago

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


a year ago

I guess I can fallback to using a Dockerfile 🙂


a year 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


a year ago

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

Maybe this should work but I'm not sure...


a year ago

Can try it for sure!


a year ago

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


a year ago

Ok we're getting somewhere!


a year ago

It copied all the files for some reason tho


a year ago

1386533495656157214


a year ago

1386533598756077598


a year ago

I see this in the build logs


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

a year ago

anyway, i've opened an issue

also if you would like, Nixpacks is an option


a year ago

ew Nixpacks no thank you


a year ago

This seems to have the same result for some reason. Just copied all the files in my project into the /app directory


a year ago

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


a year ago

I appreciate you debugging and assisting!


a year ago

oof


a year ago

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

1386536131218243684


a year ago

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


a year ago

you may need to include app/bin or may not


a year ago

oh seems like there's deployOutputs

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

a year ago

1386540327535382679


a year ago

Railway didn't like that syntax 😄


a year ago

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


a year ago

Thanks again for your time!


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

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


a year 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)


a year 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


a year 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 🐐


a year ago

!remindme read this later


a year ago

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


Welcome!

Sign in to your Railway account to join the conversation.

Loading...