From 72ea0f2ccbe45c53bba377bafa2637d9270cfce5 Mon Sep 17 00:00:00 2001 From: AEnterprise Date: Sun, 31 Aug 2025 12:50:50 +0200 Subject: [PATCH 1/3] move images to their own storage so we don't lose them on every update --- Dockerfile | 33 ++++++++++++++++++++++----------- docker-compose.dev.yml | 2 +- docker-compose.mysql.yml | 2 +- docker-compose.postgres.yml | 2 +- koel-entrypoint | 8 ++++++++ 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 089620a..46580fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,8 @@ ARG KOEL_VERSION_REF=v7.14.0 # Download the koel release matching the version and remove anything not necessary for production RUN curl -L https://github.com/koel/koel/releases/download/${KOEL_VERSION_REF}/koel-${KOEL_VERSION_REF}.tar.gz | tar -xz -C /tmp \ + && chown www-data:www-data /tmp/koel \ + && chmod 755 /tmp/koel \ && cd /tmp/koel/ \ && rm -rf .editorconfig \ .eslintignore \ @@ -73,12 +75,6 @@ RUN apt-get update \ zip \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ - # Create the music volume so it has the correct permissions - && mkdir /music \ - && chown www-data:www-data /music \ - # Create the search-indexes volume so it has the correct permissions - && mkdir -p /var/www/html/storage/search-indexes \ - && chown www-data:www-data /var/www/html/storage/search-indexes \ # Set locale to prevent removal of non-ASCII path characters when transcoding with ffmpeg # See https://github.com/koel/docker/pull/91 && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ @@ -99,16 +95,31 @@ RUN cp -R /tmp/koel/. /var/www/html RUN [ ! -f /var/www/html/public/manifest.json ] && cp /var/www/html/public/manifest.json.example /var/www/html/public/manifest.json || true RUN chown -R www-data:www-data /var/www/html -# Create /tmp/koel if it doesn't exist, and set ownership to www-data -RUN mkdir -p /tmp/koel \ - && chown www-data:www-data /tmp/koel \ - && chmod 755 /tmp/koel +RUN mkdir /music \ + && chown www-data:www-data /music \ + && mkdir -p /images/artists \ + && mkdir -p /images/avatars \ + && mkdir -p /images/covers \ + && mkdir -p /images/playlists \ + && mkdir -p /images/radio-stations \ + && chown -R www-data:www-data /images \ + && chmod -R 755 /images \ + # redirect public img storage into the cache, putting this here and not with the other koel file setups because it makes more sense here, and they are empty folder so don't have a significant impact on file size + && rm -r /var/www/html/public/img/artists \ + && rm -r /var/www/html/public/img/avatars \ + && rm -r /var/www/html/public/img/covers \ + && rm -r /var/www/html/public/img/playlists \ + && ln -s /images/artists /var/www/html/public/img/artists \ + && ln -s /images/avatars /var/www/html/public/img/avatars \ + && ln -s /images/covers /var/www/html/public/img/covers \ + && ln -s /images/playlists /var/www/html/public/img/playlists \ + && ln -s /images/radio-stations /var/www/html/public/img/radio-stations # Volumes for the music files and search index # This declaration must be AFTER creating the folders and setting their permissions # and AFTER changing to non-root user. # Otherwise, they are owned by root and the user cannot write to them. -VOLUME ["/music", "/var/www/html/storage/search-indexes"] +VOLUME ["/music", "/var/www/html/storage/search-indexes", "/images"] RUN cd /var/www/html \ && php artisan route:cache \ diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 48c0eb8..2dd4137 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -19,7 +19,7 @@ services: - DB_PASSWORD=password volumes: - music:/music - - covers:/var/www/html/public/img/covers + - images:/images - search_index:/var/www/html/storage/search-indexes - ./.env.koel:/var/www/html/.env - ./sql:/docker-entrypoint-initdb.d diff --git a/docker-compose.mysql.yml b/docker-compose.mysql.yml index 0b52d5e..4e85526 100644 --- a/docker-compose.mysql.yml +++ b/docker-compose.mysql.yml @@ -15,7 +15,7 @@ services: - DB_DATABASE=koel volumes: - music:/music - - covers:/var/www/html/public/img/covers + - images:/images - search_index:/var/www/html/storage/search-indexes - ./sql:/docker-entrypoint-initdb.d diff --git a/docker-compose.postgres.yml b/docker-compose.postgres.yml index bbfabe8..2ebf021 100644 --- a/docker-compose.postgres.yml +++ b/docker-compose.postgres.yml @@ -16,7 +16,7 @@ services: - DB_DATABASE=koel volumes: - music:/music - - covers:/var/www/html/public/img/covers + - images:/images - search_index:/var/www/html/storage/search-indexes database: diff --git a/koel-entrypoint b/koel-entrypoint index cf21cd4..d3564e5 100755 --- a/koel-entrypoint +++ b/koel-entrypoint @@ -2,6 +2,14 @@ set -e +echo "Creating image directories if needed..." +mkdir -p /images/artists \ + && mkdir -p /images/avatars \ + && mkdir -p /images/covers \ + && mkdir -p /images/playlists \ + && mkdir -p /images/radio-stations \ + && chown www-data:www-data /images/* + # Change to program root directory. cd /var/www/html From 216589329d035dbae803c521042fc54d04bbec22 Mon Sep 17 00:00:00 2001 From: AEnterprise Date: Sun, 31 Aug 2025 16:24:55 +0200 Subject: [PATCH 2/3] also link radio-stations to images --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 46580fa..da69af4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -109,10 +109,12 @@ RUN mkdir /music \ && rm -r /var/www/html/public/img/avatars \ && rm -r /var/www/html/public/img/covers \ && rm -r /var/www/html/public/img/playlists \ + && rm -r /var/www/html/public/img/radio-stations \ && ln -s /images/artists /var/www/html/public/img/artists \ && ln -s /images/avatars /var/www/html/public/img/avatars \ && ln -s /images/covers /var/www/html/public/img/covers \ && ln -s /images/playlists /var/www/html/public/img/playlists \ + && ln -s /images/radio-stations /var/www/html/public/img/radio-stations \ && ln -s /images/radio-stations /var/www/html/public/img/radio-stations # Volumes for the music files and search index From 61c14f668cd8060b45c9961f4ebfb9df2b81907c Mon Sep 17 00:00:00 2001 From: AEnterprise Date: Sun, 31 Aug 2025 16:43:47 +0200 Subject: [PATCH 3/3] remove comment --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index da69af4..6ccbdcc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -104,7 +104,6 @@ RUN mkdir /music \ && mkdir -p /images/radio-stations \ && chown -R www-data:www-data /images \ && chmod -R 755 /images \ - # redirect public img storage into the cache, putting this here and not with the other koel file setups because it makes more sense here, and they are empty folder so don't have a significant impact on file size && rm -r /var/www/html/public/img/artists \ && rm -r /var/www/html/public/img/avatars \ && rm -r /var/www/html/public/img/covers \