Building with Docker when using Cargo workspaces

I'm using Cargo Workspaces for my project, and I've managed to get everything running fine, the only thing left is me creating Docker files for it. Now the problem is, with the Dockerfile's I've made for the two workspace members, I get an error (on both workspace members) when I try to run the project (with docker-compose). I'm not too sure what to do as I'm not too sure what version the root Cargo.toml is trying to inherit (especially since it's set already).

  • This is the root project's Cargo.toml looks like: Workbin
  • This is the Dockerfile for each workspace member: Workbin
  • This is the project structure:
.
├── Cargo.toml
├── docker-compose.yaml
├── api
    ├── Cargo.toml
    ├── Dockerfile
├── cdn
    ├── Cargo.toml
    ├── Dockerfile

Thank you! :slight_smile:

You are trying to copy stuff to the root. You are also manually copying Cargo manifests, source files/directories, and other stuff one-by-one. You shouldn't be doing either of those. If you don't understand Docker well enough, then you'll screw up the COPY commands and nothing will be at the place you want it to be.

Just copy the whole project root to a (preferably non-root) working directory in one step, and .dockerignore the useless/big artifacts (e.g. target/ directories). Example.

2 Likes

The example is no longer available

That's unfortunate. I didn't do that, though – it looks like they don't keep files forever.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.