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.

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` : set a value to prevent 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` Preload and optimize the config. This disables your ability to do config edits while the container is running. If you enable this every config change will require a container restart to apply.

## 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
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just more compatible, it's not using anything bash related


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 $@
28 changes: 28 additions & 0 deletions koel-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

if [[ ! -f /var/www/html/.env ]]; then
echo "No .env file found in /var/www/html, please make sure to mount an .env config file to store the configuration, you can use the koel:init command for a guided setup"
echo ""
echo "See https://github.com/koel/docker?tab=readme-ov-file#the-koelinit-command for more information about the init command"
echo "See https://github.com/koel/koel/blob/master/.env.example for an example env file if you want to change other configuration options as well or do a manual setup"
exit 0
fi

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

if [[ -z "${OPTIMIZE_CONFIG}" ]]; then
echo "Config not optimized, if your config is locked in you can enable the OPTIMIZE_CONFIG option. Enabling this will optimize your config, but YOU WILL NOT BE ABLE TO MAKE CONFIG EDITS WITHOUT RESTARING THE CONTAINER"
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 "Skipped init, koel might not be able to run if it is misconfigured or your database is out of date. This should not be used outside of debugging or manual initial setups!"
fi