1

My goal is to share source files between some machines, but not all. In this example, machine_a and machine_b have source directories that are exact copies of each other an I'd like to combine them together somehow to reduce the duplication.

recipe/
    machine_a/
        script_1.sh
        script_2.sh
    machine_b/
        script_1.sh
        script_2.sh
    machine_c/
        script_3.sh

I've tried symbolically linking machine_b/ to machine_a/ as well as linking the individual source files (machine_b/script_1.sh -> machine_a/script_1.sh etc) but the problem is that since the build is done in a docker container and the do_fetch() task doesn't perform a deep copy, the build can't access the original source file.

I can think of other ways like changing MACHINE_NAME inside the recipe, but I don't think that'd work cleanly.

What's the best way to accomplish this?

andrey
  • 61
  • 6

1 Answers1

0

You could issue a bind mount. So instead of linking the folder you want to merge, just mount the folder that is supposed to be the same in the second place where you want this.

recipe/
├─ machine_a/
│  ├─ script_1.sh
│  ├─ script_2.sh
├─ machine_b      <-- mount the folder for machine_a here/
├─ machine_c/
│  ├─ script_3.sh

so in this example the command would look, more or less like this:

$ sudo mount --bind recipe/machine_a recipe/machine_b

then if it worked, add the mount to your /etc/fstab

Mikesco3
  • 36
  • 5
  • The problem with that solution is that since it's a OS-level feature it can't be tracked in a version control system. That is, to someone downloading the repository there would be no link between those directories. – andrey Nov 14 '22 at 21:50
  • This would accomplish what you originally asked for and properly build the docker containers. You could explain the fact that they are linked in documentation. Unless you just want to make docker build machine_b from the image of machine_a. – Mikesco3 Nov 14 '22 at 22:01