softprops / lambda-rust

🐳 🦀 a dockerized lambda build env for rust applications
MIT License
162 stars 76 forks source link

Running from subdirectory #63

Closed Luminoth closed 4 years ago

Luminoth commented 4 years ago

I have a lambda project that uses a local path dependency that looks like this in the Cargo.toml:

[dependencies.logger]
path = "../../libs/logger"

That's posing a problem for using the builder since it assumes everything lives top-level in /code. Is there any way to pass in that entry point rather than assuming it's always going to be /code ? Or maybe some way to work around the local dependency problem?

Luminoth commented 4 years ago

If I'm understanding how the setup works, it should just be a matter of adding an ENV for the WORKDIR in the Dockerfile?

softprops commented 4 years ago

Do you use cargo workspaces? If so, workspaces are supported. These let you share dependencies between crates in a single project.

Can you elaborate a bit more on your project structure if it's not setup as a cargo workspace?

Luminoth commented 4 years ago

Unfortunately, we don't use Cargo workspaces, as much as I wish we did. We have essentially some disjoint Rust libs and a couple Rust apps inside of a much much larger C++ mono repo structure. Using the local dependencies has so far been the easiest way of massaging all of it together without upending the C++ centric build system.

Luminoth commented 4 years ago

Actually, doing some Docker learning today and it looks like I can probably accomplish this using -w to override the WORKDIR.

softprops commented 4 years ago

Good to hear. If you have time, I'd be happy take a pull to update the readme with similar example in case others hit the same issue.