Update Dev Container setup with SoftSqueeze support#1552
Conversation
|
Thanks! I had seen your branch and it intrigued me. I never really used dev containers, and running them on Github directly showed quite a few limitations with a free account. But this should still be a good addition. Before I go into great details: why Softsqueeze, but no squeezelite of Squeezeplay? I believe the latter are way more popular (and important nowadays) than the former. |
|
The advantage of Dev Containers is that you don't need any additional tools for local development—everything is included in a single "package." Yes, you’re right, SoftSqueeze isn’t popular anymore, but I’m working on an improvement regarding bitmap fonts, and SoftSqueeze is perfect for that. And I didn’t want to install it locally. I can set up other containers, but there are certainly sound issues, especially when the host is Windows. |
michaelherger
left a comment
There was a problem hiding this comment.
Thanks a lot! I will definitely have to give this a try! I've never been able to debug LMS... this would be a first.
Maybe you could add a section to DEVCONTAIERS.md explaining how to map a music folder to the container? Or did I miss that?
| - `Cache/` | ||
| - `Logs/` | ||
| - `prefs/` |
There was a problem hiding this comment.
Would these folders live in the clone's root? Any way to move this elsewhere?
There was a problem hiding this comment.
Yes, it is possible to mount this paths as volume. I can add this as option to the image
There was a problem hiding this comment.
It depends on what you want—whether to use the project's root directory or something else. I prefer the project's root directory, which is slimserver's default behavior.
| cd "$REPO_ROOT" | ||
|
|
||
| if [[ "$FORCE" != "1" ]]; then | ||
| echo "[INFO] This will delete: ${FOLDERS_TO_CLEAN[*]}" |
There was a problem hiding this comment.
Would be good to show the full list. Just to not get nervous about it.
There was a problem hiding this comment.
Good point, I'll do that
| "/workspaces/slimserver/CPAN/arch/5.40/x86_64-linux-thread-multi", | ||
| "/workspaces/slimserver/CPAN/arch/5.40/x86_64-linux-thread-multi/auto", |
There was a problem hiding this comment.
Can this be made platform independent? I'm a Mac user...
There was a problem hiding this comment.
I'll give it a try. I was worried it wouldn't work for everyone, but I don't have a way to test it—I'm on Windows.
There was a problem hiding this comment.
Updated, you can try.
| @@ -0,0 +1,2 @@ | |||
| # Normalize all text files to LF in this repository (fix issues with line endings with Dev Containers on Windows) | |||
| * text=auto eol=lf | |||
There was a problem hiding this comment.
Will this cause any file change to change line endings, potentially "modifying" a full name just for the line endings?
There was a problem hiding this comment.
I've updated the definition; after that, we can run this script and see what changes
git add --renormalize .
git status
There was a problem hiding this comment.
The following files will be modified:
- Firmware/receiver.version
- Graphics/CODE2000.HTM
- HTML/EN/html/ext/ext-all-debug.js
- Slim/Plugin/CLI/Settings.pm
- Slim/Plugin/DateTime/Settings.pm
- Slim/Plugin/MusicMagic/HTML/EN/plugins/MusicMagic/html/docs/customtags.html
- Slim/Plugin/MusicMagic/HTML/EN/plugins/MusicMagic/html/docs/httpprotocol.html
- Slim/Plugin/MusicMagic/HTML/EN/plugins/MusicMagic/html/docs/powersearch.html
- Slim/Plugin/MusicMagic/HTML/EN/plugins/MusicMagic/html/docs/powerwords.html
- Slim/Plugin/Podcast/ProtocolHandler.pm
- Slim/Plugin/Podcast/Settings.pm
- Slim/Plugin/RS232/Settings.pm
- Slim/Plugin/Rescan/Settings.pm
- Slim/Plugin/UPnP/HTML/EN/plugins/UPnP/MediaServer/MediaReceiverRegistrar.xml
- Slim/Plugin/iTunes/Settings.pm
- Slim/Plugin/xPL/Settings.pm
Is this okay, or should I add some exceptions to the .gitattributes file?
There was a problem hiding this comment.
Thanks for looking into this! I think I could live with this list of files being changed. Would that happen with this PR, or the first time they'd be touched?
There was a problem hiding this comment.
In my opinion, it would be a good idea to add these files to this PR. Those files would only be affected the first time someone explicitly runs git add --renormalize. after pulling the .gitattributes change — existing checkouts won't be silently modified
|
First attempt failed. Trying to run using F5 would bring up the debug panel, but no output whatsoever. And after a second or two it stops. Might be the platform is an issue here? The container was created for ARM (Apple Silicon). I tried tweaking all x86_64 paths to use the aarch64 version instead. But still: no feedback, no LMS running. Then tried to run LMS manually (inside the container): Would probably be good to add |
|
It must be challenging to develop without debugging. Yes, the "issue" is the platform. I'll try to fix it, but I don't have a way to test it, so it's good that you have a Mac. I'll also add the music paths as volume mount. |
|
Updated—I hope it works for you too. |
There was a problem hiding this comment.
Something about this configuration file must be wrong/incomplete: after I had tried out your PR my indenting was set to spaces all over the place. Not in VSCode, but something overrode the setting I have in VSCode. All my existing code which was using tabs before (incl. LMS) suddenly started using spaces. Did this not happen to you?
There was a problem hiding this comment.
Perhaps the "editorconfig.editorconfig" extension has been installed (see .vscode/extensions.json), so every project you open uses this extension? The files are formatted correctly in the LMS, right?
- Updated devcontainer.json to include environment variables and commands for initialization and startup. - Configured editor settings and added necessary files for Perl Language Server integration. - Developed a standalone SoftSqueeze container with VNC support, including entrypoint and management scripts. - Added initialization script to create a shared network for containers. - Implemented post-create and post-start scripts for LMS setup and auto-start functionality. - Introduced a clean-up script to remove runtime-generated folders. - Enhanced documentation for Dev Container usage, SoftSqueeze setup, and troubleshooting. Signed-off-by: mipa87 <62723159+mipa87@users.noreply.github.com>
- Updated Dockerfile to include necessary packages and environment variables. - Improved clean-folders.sh to provide clearer output on folder deletion. - Modified devcontainer.json to include optional mounts for host folders. - Added engine-utils.sh for better container engine detection. - Refactored initialize.sh to utilize engine-utils for container engine selection. - Updated post-start.sh to execute a new start-lyrion.sh script for starting LMS. - Enhanced SOFTSQUEEZE.md with clearer instructions and tips for SoftSqueeze usage. - Improved softsqueeze.sh to support both podman and docker with compose. - Created start-lyrion.sh for streamlined LMS startup process. - Updated .gitattributes and .gitignore for better file handling. - Refined PerlLanguageServerBootstrap.pm for improved module loading. - Updated extensions.json and launch.json for better VS Code integration. - Enhanced DEVCONTAINERS.md with clearer instructions for running and stopping Lyrion. Signed-off-by: mipa87 <62723159+mipa87@users.noreply.github.com>
…and enhance documentation Signed-off-by: mipa87 <62723159+mipa87@users.noreply.github.com>
|
|
||
| For Podman, set [`dev.containers.dockerPath`](vscode://settings/dev.containers.dockerPath) to `podman`, and set [`dev.containers.dockerComposePath`](vscode://settings/dev.containers.dockerComposePath) to `podman compose`. | ||
|
|
||
| > [!TIP] |
There was a problem hiding this comment.
You mention WSL but don't say whether this was Windows specific. Is it?
There was a problem hiding this comment.
Good catch! Clarified that the WSL memory tip is Windows-specific — it no longer sounds like it applies to everyone.
| ```bash | ||
| bash .devcontainer/start-lyrion.sh | ||
| ``` | ||
|
|
||
| The script waits until Lyrion is reachable and prints the URL. | ||
|
|
||
| Alternatively, start it directly with Perl: | ||
|
|
||
| ```bash | ||
| perl slimserver.pl | ||
| ``` |
There was a problem hiding this comment.
I personally prefer to run directly so I immediately have the log output in the console. AND it supports an IMHO super helpful feature for CLI interaction: if you set an environment variable LMS_STDIO=1 you'll be able to directly type CLI commands in the console while LMS is run directly. I like to use that when working on those commands and queries. Maybe that's worth a note?
There was a problem hiding this comment.
Great tip, I wasn't aware of that! Added a note right under the direct perl slimserver.pl launch option — it now mentions LMS_STDIO=1 and the interactive CLI feature. Thanks!
There was a problem hiding this comment.
Heh... just checked. Must be one of the most useful und non-documented features we have (for developers). I should add a note to the web site, too.
| 4. Open the **Ports** tab and click the **Forwarded Address** `Web interface` to access Lyrion web UI [^2]. | ||
| [^2]: For local Dev Containers you can also open [http://localhost:9000](http://localhost:9000) directly. |
There was a problem hiding this comment.
In VSC the printed link is clickable. So that's nice.
Unfortunately I'm hitting permissions issues:
[26-05-11 07:33:24.9826] Slim::Web::Template::SkinManager::_fillTemplate (351) Error: file error - cache failed to write bd362145801a53228f4dab32cd311917: Error in tempfile() using /workspaces/git/server/Cache/templates/XXXXXXXXXX: Parent directory (/workspaces/git/server/Cache/templates/) is not writable
That's just one example. I don't even find a libarary.db. Could this (again) be a macOS issue? That's to first say: thanks! Yes, the dev container now does run on macOS. But unfortunately there's probably more to tweak...
drwxr-xr-x 1 503 dialout 288 May 11 07:34 prefs
Interestingly the same permissions seem to be fine for Logs.
There was a problem hiding this comment.
Added mkdir -p Cache Logs prefs to post-create.sh, which runs inside the container immediately after creation (as the container user). This ensures the runtime directories are owned by the right user before LMS ever tries to write to them.
Regarding the path /workspaces/git/server — that looks like you might be using "Clone Repository in Container Volume", which places the repo under a slightly different path. The "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}" in devcontainer.json should resolve correctly regardless of the folder name. Let me know if the permissions issue persists!
| ### Manual Stop | ||
|
|
||
| ```bash | ||
| bash .devcontainer/stop-lyrion.sh |
There was a problem hiding this comment.
Probably another macOS issue: most scripts don't have executable flag set.
vscode ➜ /workspaces/git/server $ ls -l .devcontainer/
total 44
-rw-r--r-- 1 503 dialout 1430 May 11 07:28 Dockerfile
-rw-r--r-- 1 503 dialout 853 May 11 07:28 clean-folders.sh
-rw-r--r-- 1 503 dialout 3988 May 11 07:28 devcontainer.json
-rw-r--r-- 1 503 dialout 482 May 11 07:27 docker-compose.yml
-rw-r--r-- 1 503 dialout 2091 May 11 07:27 engine-utils.sh
-rw-r--r-- 1 503 dialout 907 May 11 07:27 initialize.sh
-rwxr-xr-x 1 503 dialout 966 May 11 07:27 post-create.sh
-rw-r--r-- 1 503 dialout 338 May 11 07:27 post-start.sh
drwxr-xr-x 1 503 dialout 224 May 11 07:27 softsqueeze
-rw-r--r-- 1 503 dialout 1235 May 11 07:28 start-lyrion.sh
-rw-r--r-- 1 503 dialout 717 May 11 07:27 stop-lyrion.sh
Wouldn't it be possible to fix that so we don't have to use bash explicitly?
There was a problem hiding this comment.
Fixed! Set the executable bit on all .sh scripts via git update-index --chmod=+x — they were all 100644. You can now run them directly without the bash prefix, and I've updated the docs accordingly.
I've also added a find .devcontainer -name "*.sh" -exec chmod +x {} + fallback to post-create.sh as a safety net for any checkout where the bit gets lost, and added a short note to the docs: for any new scripts added to .devcontainer/, the bit needs to be set explicitly with git update-index --chmod=+x.
michaelherger
left a comment
There was a problem hiding this comment.
I'm sorry for the long delay. Had some "life issues" to deal with 😁. And your PR is a lot of work which deserves attention! As you had seen from my earlier attempts, I never really made the concept work. You're much closer already!
In a previous comment I mentioned permissions issues. But I believe out of the box it's even worse: LMS wouldn't start at all if the three working folders didn't exist yet:
vscode ➜ /workspaces/git/server $ perl slimserver.pl
[26-05-11 07:47:24.8135] main::init (282) Starting Lyrion Music Server (v9.2.0, TRUNK, UNKNOWN) perl 5.032001 - aarch64-linux-gnu-thread-multi
[26-05-11 07:47:24.8143] Slim::Utils::Prefs::init (295) Error: unable to write to preferences directory /workspaces/git/server/prefs
cannot remove directory for /tmp/build-features-src: Operation not permitted at /workspaces/git/server/Slim/Utils/Misc.pm line 660.
cannot unlink file for /tmp/dev-container-features/devcontainer-features.builtin.env: Permission denied at /workspaces/git/server/Slim/Utils/Misc.pm line 660.
cannot restore permissions to 0100755 for /tmp/dev-container-features/devcontainer-features.builtin.env: Permission denied at /workspaces/git/server/Slim/Utils/Misc.pm line 660.
cannot remove directory for /tmp/dev-container-features: Operation not permitted at /workspaces/git/server/Slim/Utils/Misc.pm line 660.
[26-05-11 07:47:24.8979] Slim::Utils::PluginDownloader::init (59) unable to store downloads in cachedir
[26-05-11 07:47:25.2865] YAML::XS::DumpFile (31) Warning: Can't open '/plugin-data.yaml' for output:
Permission denied at /workspaces/git/server/CPAN/YAML/XS.pm line 31.
That's the biggest bummer for me right now. The other one I noticed (when it was somewhat running) was the lack of IO::Socket::SSL support? I don't get it, as should be installed by the Dockerfile definition? Is there a way to for me to see the output of that container creation?
I'll play around some more. Hopefully I'll find some answers, too. Nice work!
…entation for script usage Signed-off-by: mipa87 <62723159+mipa87@users.noreply.github.com>
…cpanm Signed-off-by: mipa87 <62723159+mipa87@users.noreply.github.com>
|
No worries at all — take your time! 🙂 And thanks for actually testing on macOS/Apple Silicon, that's invaluable. Let me go through the issues: The The I've moved Thanks again for the patience and the detailed feedback, it really helps! |
|
Thanks for the updates! Unfortunately my main concerns still aren't fixed: permissions and SSL. I don't get it. I deleted containers/images before pulling the latest changes. I saw it re-build them when I first tried to switch to devcontainer mode. Cache/Logs/prefs folders were re-built, and partially populated: I see .db files in cache and prefs, Permissions IMHO are about the same everywhere, with the user ID being We have code in LMS which would try to lower the user level if run as root. Maybe this is the culprit here: some of the logging/DB/etc. infrastructure is initialised before that, but prefs aren't? Is the server run as root inside the container? FWIW: I'm using the Colima runtime, rather than Docker (https://github.com/abiosoft/colima). I don't know whether that matters, tbh. But I've never had these kinds of issues with the few containers I'm usually running on that machine. What do you think? Should we merge anyway, and see what others' experience is? Rather than stress this potentially somewhat exotic setup I'm using? |
Everything has been tested - Docker Compose and Dockerfile, GitHub Codespaces and Dev Containers, Podman (Docker should be compatible) — on both Windows and GitHub Codespaces on Linux.
I hope this makes development easier for new Perl developers like me 🙂