Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
!/apache.conf
!/php.ini
!/koel-entrypoint
!/koel-init
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ ENV FFMPEG_PATH=/usr/bin/ffmpeg \

# Setup bootstrap script.
COPY koel-entrypoint /usr/local/bin/
COPY koel-init /usr/local/bin/
ENTRYPOINT ["koel-entrypoint"]
CMD ["apache2-foreground"]

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ docker-compose -f ./docker-compose.postgres.yml up -d

## The `koel:init` command

This command is automatically ran when the container starts, but can be disabled if you want to do some manual adjustments first. As such it is often sufficient to provide the needed env variables to the container to setup koel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current text is pretty cryptic (e.g., what are "some manual adjustments" and what does "providing the needed env variables to the container" mean? I am the author of koel and I'm still having a hard time trying to wrap my head around it 🙂). Can ChatGPT help us here?
Also I don't think this paragraph doesn't blend well with the whole section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how to word it better. the manul thing is more using the php commands to figue out why things don't work when the init fails entirely

this should be pretty rare though unless koel itself is broken completely already


For the first installation and every subsequent upgrade, you will need to run the `koel:init` command, which handles migrations and other setup tasks.
For instance, during the first run, this command will generate the `APP_KEY`, create the default admin user, and initialize the database. For subsequent runs, it will apply any new migrations and update the database schema as needed.

Expand Down Expand Up @@ -189,6 +191,7 @@ For all new songs, the search index will be automatically populated by `php arti
> [!IMPORTANT]
> This list is not exhaustive and may not be up-to-date. See [`.env.example`][koel-env-example] for a complete reference.

- `SKIP_INIT`: Prevents the container from automatically running the init script on startup.
- `DB_CONNECTION`: `mysql` OR `pgsql` OR `sqlsrv` OR `sqlite-persistent`. Corresponds to the type of database being used with Koel.
- `DB_HOST`: `database`. The name of the Docker container hosting the database. Koel needs to be on the same Docker network to find the database by its name.
- `DB_USERNAME`: `koel`. If you change it, also change it in the database container.
Expand All @@ -199,6 +202,7 @@ For all new songs, the search index will be automatically populated by `php arti
- `MEMORY_LIMIT`: The amount of memory in MB for the scanning process. Increase this value if `php artisan koel:scan` runs out of memory.
- `LASTFM_API_KEY` and `LASTFM_API_SECRET`: Enables Last.fm integration. See https://docs.koel.dev/3rd-party.html#last-fm
- `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET`: Enables Spotify integration. See https://docs.koel.dev/3rd-party.html#spotify
- `OPTIMIZE_CONFIG` Preloads and optimizes koel's configuration. This disables config modifications while the container is running. If you enable this, every change to the configuration will require a container restart to be applied.

## Volumes

Expand Down
5 changes: 4 additions & 1 deletion koel-entrypoint
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash
#!/bin/sh

set -e

# Change to program root directory.
cd /var/www/html

# Run the koel-init script to (optionally) optimize configs and (optionally) run initialize/update koel
su -s '/bin/sh' -c "/usr/local/bin/koel-init" www-data

# Run the next entrypoint in the chain.
echo "running docker-php-entrypoint with arguments $@"
docker-php-entrypoint $@
27 changes: 27 additions & 0 deletions koel-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

if [[ ! -f /var/www/html/.env ]]; then
echo "No .env file found in /var/www/html. Make sure to mount a .env file to store the configuration. You can use the koel:init command (see https://github.com/koel/docker#the-koelinit-command) for a guided setup."
echo ""
echo "See https://github.com/koel/koel/blob/master/.env.example for an example .env file."
exit 0
fi

if [[ -z "${SKIP_INIT}" ]]; then

if [[ -z "${OPTIMIZE_CONFIG}" ]]; then
echo "Config not optimized. You can optimize the config with `OPTIMIZE_CONFIG`. Note that this will prevent config modifications from being applied until the container is restarted."
else
echo "Optimizing config..."
# clear before caching, in case this is a container reboot and it was already cached from before
php artisan config:clear
php artisan config:cache
fi

# Invoke the init script so database migrations run and the config is at least partially validated
echo "Running installer..."
php artisan koel:init --no-assets --no-interaction
php artisan koel:doctor
else
echo "Initialization skipped. koel might not work properly if it is misconfigured or if the database is out of date. This should not be used outside of debugging or manual initial setups!"
fi