Support mounting volumes and init hooks via config#332
Conversation
d367c1f to
0d7b899
Compare
Add a per-container `volumes` list of Docker-style "host:container[:ro]" bind specs, enabling arbitrary mounts such as Snowflake init hooks (e.g. /etc/localstack/init/ready.d/). The persistence mount to /var/lib/localstack is folded into this list; the legacy singular `volume` field still works for backward compatibility. Relative host sources resolve against the config file's directory and a leading ~/ is expanded, since the Docker SDK treats a non-absolute source as a named volume. Extra mounts must already exist (init-hook entries are files), unlike the persistence dir which is created. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two Windows-only bugs broke `volumes` parsing:
- The container target was validated with filepath.IsAbs, which rejects
"/var/lib/localstack" on Windows (no drive). The target is always a Unix
path inside the container, so validate it with path.IsAbs (slash semantics).
- A Windows host source has a drive letter ("C:\\data"), whose ':' was
mistaken for the host:container separator. Add a drive-letter-aware
splitter, guarded to Windows so a single-letter relative host dir
("a:/data") stays valid elsewhere, matching Docker's behavior.
Make the volume unit tests OS-portable by using filepath-based absolute
sources instead of hardcoded Unix paths.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0d7b899 to
145923a
Compare
Clarify in the README and CLAUDE.md that the singular `volume` and plural `volumes` overlap only for the persistence mount: `volume` only sets the /var/lib/localstack dir and is used verbatim, while `volumes` is a superset that also handles arbitrary mounts (init hooks) and resolves relative/~ paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@mmaureenliu would you like to give it a try and see how this works for snowflake? In my test it works, but wanted to double check I'm doing the right thing. Any feedback is welcome! |
Do I just build from this branch and run it with snowflake? |
Yes, please. |
Closes DEVX-925.
Adds a per-container
volumeslist toconfig.tomlfor arbitrary bind mounts. The main use case being Snowflake init hooks (scripts mounted into/etc/localstack/init/ready.d/that run on startup)."host:container[:ro]"specs.~/is expanded (the Docker SDK treats a non-absolute source as a named volume, so this is required). Windows drive-letter sources (C:\...) are handled.volumevsvolumesThe singular
volumeand the pluralvolumesare not general synonyms; they overlap only for the persistence directory:volumeonly sets the persistent-state dir, always mounted to/var/lib/localstack(the dir managed bylstk volume path/lstk volume clear).volumesis a superset: it can mount arbitrary paths and set the persistence dir, via the entry whose container target is/var/lib/localstack.So these are equivalent for persistence:
Differences to keep in mind:
volumecannot express init hooks or any non-persistence mount — usevolumes.volumessource is path-resolved (relative → config dir,~/expanded); the legacyvolumevalue is used verbatim, so prefer an absolute path there.volumeand avolumesentry with different sources is a configuration error; the same source in both is allowed.volumestays supported for backward compatibility so existingconfig.tomldon't break.