-
Notifications
You must be signed in to change notification settings - Fork 711
-
Let's say I have a directory with my project files:
.
├── README.md
├── files
│ ├── Dockerfile
│ └── local-yum.repo
├── oraclelinux9.yaml
└── variables.yaml
In my oraclelinux9.yaml file, I have a provision section where I want to copy the files/local-yum.repo
file to some other directory in the VM.
For example:
provision: - mode: system script: | #!/bin/bash mkdir -p /var/www/html/yum cp files/local-yum.repo /var/www/html/yum/
In addition to specifying a relative path, I tried specifying cp $LIMA_WORKDIR/files/local-yum.repo /var/www/html/yum/
but that doesn't work. I also tried adding a mount so I could predict where in the VM it will show up but that doesn't seem to be working either. What is the best way to do this?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 7 replies
-
You should be able to do this with a "data" provisioning file. Something like:
provision: - mode: data file: files/local-yum.repo path: /var/www/html/yum/local-yum.repo
This also requires Lima 1.1.0-alpha.0 or later.
Beta Was this translation helpful? Give feedback.
All reactions
-
What about when/if I need a folder with several files (or if the file was a binary of sorts)?
Yes, data provisioning needs to specify each file individually.
Binary files will work as long as they are short. This can probably be fixed to work with long files too (#3403), but embedding long binary files in YAML (e.g. base64 encoded) will become unwieldy quickly.
❯ printf "\x00\x01" > binary.data ❯ hexdump -C binary.data 00000000 00 01 |..| 00000002 ❯ cat tmpl.yaml base: template://alpine provision: - mode: data file: binary.data path: /tmp/binary.data ❯ limactl tmpl copy --embed tmpl.yaml - WARN[0000] `provision[*].file` and `probes[*].file` are experimental base: template://alpine provision: - mode: data content: \x00\x01 path: /tmp/binary.data
Beta Was this translation helpful? Give feedback.
All reactions
-
Very cool that binary files can be passed through YAML as well. Thank you.
By the way, I was able to get the mount stuff working... the problem I faced yesterday is because I was using 1.1.0-alpha.0
to start the VM, but was using 1.0.7
to connect to the shell since that is what's in my environment path.
mounts: - location: files/ mountPoint: /tmp/files writable: true
The error was WARN[0000] instance "ksplice-offline" has errors errors="[field
mounts[2].location must be an absolute path, got \"files/\"]"
but I guess that's just something that isn't supported in 1.0.7
.
Beta Was this translation helpful? Give feedback.
All reactions
-
No, the mount location
must always be an absolute path, even with 1.1.0.
Things that can be relative paths are base
and provision[].file
locators, which are resolved when the instance is created, not when it is started (like the mounts).
Note that the relative locators are resolved relative to the location of the template that references them, not relative to your current directory. Assuming your recent example template:
limactl create https://example.com/oraclelinux.yaml
In that case values.yaml
will be fetched from https://example.com/values.yaml
and not from ./values.yaml
.
Beta Was this translation helpful? Give feedback.
All reactions
-
I've just created #3404 to allow combination of external templates and local settings without requiring you to create yet another local base template.
Beta Was this translation helpful? Give feedback.
All reactions
-
Binary files will work as long as they are short. This can probably be fixed to work with long files too (#3403), but embedding long binary files in YAML (e.g. base64 encoded) will become unwieldy quickly.
I've implemented embedding of binary files as multi-line base64 strings in #3421 (but has not yet been merged).
Beta Was this translation helpful? Give feedback.