Skip to content

Commit 4356c81

Browse files
phananclaude
andcommitted
rework README and fix volume declarations
- Reorganize README for a clearer flow and remove redundant database setup instructions that were duplicating what the compose files show - Add missing /var/www/html/public/img/storage volume to Dockerfile - Document all three volumes in the README Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1f8c344 commit 4356c81

2 files changed

Lines changed: 68 additions & 171 deletions

File tree

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ RUN cp -R /tmp/koel/. /var/www/html \
101101
&& mv /var/www/html/public/manifest.json.example /var/www/html/public/manifest.json \
102102
&& chown -R www-data:www-data /var/www/html
103103

104-
# Volumes for the music files and search index
104+
# Volumes for the music files, image storage, and search index
105105
# This declaration must be AFTER creating the folders and setting their permissions
106106
# and AFTER changing to non-root user.
107107
# Otherwise, they are owned by root and the user cannot write to them.
108-
VOLUME ["/music", "/var/www/html/storage/search-indexes"]
108+
VOLUME ["/music", "/var/www/html/public/img/storage", "/var/www/html/storage/search-indexes"]
109109

110110
RUN cd /var/www/html \
111111
&& php artisan route:cache \

README.md

Lines changed: 66 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -3,245 +3,142 @@ koel/docker
33

44
[![docker-pulls-badge]][docker-hub] ![Continuous testing and deployment](https://github.com/koel/docker/workflows/Continuous%20testing%20and%20deployment/badge.svg)
55

6-
A docker image with only the bare essentials needed to run [koel]. It includes Apache and a PHP runtime with required extensions.
6+
A Docker image with only the bare essentials needed to run [Koel]. It includes Apache and a PHP runtime with required extensions.
77

88
> [!IMPORTANT]
9-
> This container does not include a database. It **requires** another container to handle the database.
9+
> This image does not include a database. A separate database container (MariaDB/MySQL or PostgreSQL) is required.
10+
> Ready-to-use Docker Compose configurations are provided — see [Quick Start](#quick-start).
1011
11-
## Usage
12+
## Quick Start
1213

13-
Since [Koel supports many databases][koel-requirements] you are free to choose any Docker image that hosts one of those databases.
14-
15-
`koel/docker` (this image) has been tested with MariaDB/MySQL and PostgreSQL.
16-
17-
### Run with docker-compose and MariaDB/MySQL
18-
19-
[docker-compose] is the easiest way to get started. It will start both the database container and this image.
20-
Clone this repository and edit `docker-compose.mysql.yml`. **Make sure to replace passwords !**
21-
22-
Check out the [`./docker-compose.mysql.yml`](<./docker-compose.mysql.yml>) file for more details.
23-
24-
Then run `docker-compose`:
14+
[Docker Compose][docker-compose] is the easiest way to get started. Clone this repository, pick a compose file for your preferred database, update the passwords, and run:
2515

2616
```bash
27-
docker-compose -f ./docker-compose.mysql.yml up -d
28-
```
29-
30-
### Run with docker-compose and PostgreSQL
31-
32-
Clone this repository and edit `docker-compose.postgres.yml`. **Make sure to replace passwords !**
17+
# For MariaDB/MySQL
18+
docker compose -f docker-compose.mysql.yml up -d
3319

34-
Check out the [`./docker-compose.postgres.yml`](<./docker-compose.postgres.yml>) file for more details.
35-
36-
Then run `docker-compose`:
37-
38-
```bash
39-
docker-compose -f ./docker-compose.postgres.yml up -d
20+
# For PostgreSQL
21+
docker compose -f docker-compose.postgres.yml up -d
4022
```
4123

42-
## The `koel:init` command
43-
44-
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.
24+
## Initial Setup
4525

46-
For the first installation and every subsequent upgrade, you will need to run the `koel:init` command, which handles migrations and other setup tasks.
47-
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.
26+
### The `koel:init` command
4827

49-
In order to run this command, you first need to `exec` into the container (replace `<container_name_for_koel>` with the name of your running Koel container):
28+
This command handles migrations, generates the `APP_KEY`, creates the default admin account, and performs other first-run tasks. It runs automatically when the container starts (disable with `SKIP_INIT=true`), but you can also run it manually:
5029

5130
```bash
52-
docker exec --user www-data -it <container_name_for_koel> bash
31+
docker exec --user www-data -it <koel_container> php artisan koel:init --no-assets
5332
```
5433

55-
Once inside the container, run the `koel:init` command:
56-
57-
```bash
58-
# --no-assets option tells the init command to skip building the front-end assets,
59-
# as they have already been built and included in the Koel's installation archive.
60-
$ php artisan koel:init --no-assets
61-
```
62-
63-
When prompted, provide `database` as the database host, `koel` as both the database name and username, and the password you set when
64-
creating the database container.
34+
The `--no-assets` flag skips building front-end assets, as they are already included in the image.
6535

6636
### Default admin account
6737

68-
During the first `koel:init`, Koel creates the default admin account for you. The credentials are as follows:
69-
70-
* Email: `admin@koel.dev`
71-
* Password: `KoelIsCool`
72-
73-
For security purposes, run the following command to update the account's password **before using Koel**:
74-
75-
```bash
76-
docker exec -it <container_name_for_koel> php artisan koel:admin:change-password
77-
```
78-
79-
You can also update the account (including the email) using the web interface after logging in.
38+
The first `koel:init` creates a default admin account:
8039

81-
### Run manually with MariaDB/MySQL
40+
* **Email:** `admin@koel.dev`
41+
* **Password:** `KoelIsCool`
8242

83-
Create a docker network. It will be shared by Koel and its database.
43+
**Change this password immediately:**
8444

8545
```bash
86-
docker network create --attachable koel-net
46+
docker exec -it <koel_container> php artisan koel:admin:change-password
8747
```
8848

89-
Create a database container. Here we will use [mariadb].
49+
You can also update the email and password via the web interface after logging in.
9050

91-
```bash
92-
docker run -d --name database \
93-
-e MYSQL_ROOT_PASSWORD=<root_password> \
94-
-e MYSQL_DATABASE=koel \
95-
-e MYSQL_USER=koel \
96-
-e MYSQL_PASSWORD=<koel_password> \
97-
--network=koel-net \
98-
-v koel_db:/var/lib/mysql \
99-
mariadb:10.11
100-
```
101-
102-
Create the koel container on the same network so they can communicate
103-
104-
```bash
105-
docker run -d --name koel \
106-
-p 80:80 \
107-
-e DB_CONNECTION=mysql \
108-
-e DB_HOST=database \
109-
-e DB_DATABASE=koel \
110-
-e DB_USERNAME=koel \
111-
-e DB_PASSWORD=<koel_password> \
112-
--network=koel-net \
113-
-v music:/music \
114-
-v image_storage:/var/www/html/public/img/storage \
115-
-v search_index:/var/www/html/storage/search-indexes \
116-
phanan/koel
117-
```
51+
## Configuration
11852

119-
The same applies for the first run. See the [First run section](#first-run).
53+
### Preserving `APP_KEY`
12054

121-
### How to bind-mount the `.env` file
55+
`APP_KEY` is generated during `koel:init` and is essential for encryption. If the container is recreated without persisting this key, you'll need to re-initialize. Two ways to preserve it:
12256

123-
To be sure to preserve `APP_KEY` you can choose to bind-mount the `.env` file to your host:
57+
**Option 1: Bind-mount the `.env` file**
12458

12559
```bash
126-
# On your host, create an `.env` file
12760
touch .env
128-
129-
# Then, you can bind-mount it directly in the container
13061
docker run -d --name koel \
13162
-p 80:80 \
13263
--mount type=bind,source="$(pwd)"/.env,target=/var/www/html/.env \
13364
phanan/koel
134-
135-
docker exec --user www-data -it koel bash
136-
137-
# In the container, run koel:init command with --no-assets flag
138-
$ php artisan koel:init --no-assets
13965
```
14066

141-
### Pass environment variables
142-
143-
Once you have generated an `APP_KEY` you can provide it as environment variables to your container to preserve it.
67+
**Option 2: Pass `APP_KEY` as an environment variable**
14468

14569
```bash
146-
# Run a container just to generate the key
147-
docker run -it --rm phanan/koel bash
148-
# In the container, generate APP_KEY
149-
$ php artisan key:generate --force
150-
# Show the modified .env file
151-
$ cat .env
152-
# Copy the APP_KEY variable, and exit the container
153-
$ exit
154-
```
70+
# Generate a key
71+
docker run -it --rm phanan/koel php artisan key:generate --show
15572

156-
You can then provide the variables to your real container:
157-
158-
```bash
73+
# Pass it to your container
15974
docker run -d --name koel \
16075
-p 80:80 \
16176
-e APP_KEY=<your_app_key> \
16277
phanan/koel
163-
# Even better, write an env-file in your host and pass it to the container
164-
docker run -d --name koel \
165-
-p 80:80 \
166-
--env-file .koel.env \
167-
phanan/koel
16878
```
16979

170-
### Scan media folders
171-
172-
Koel's init script installs a [scheduler](https://docs.koel.dev/cli-commands#command-scheduling) that scans the `/music` folder daily for new music.
173-
You can also trigger a manual scan at any time by running the following command:
174-
175-
```bash
176-
docker exec --user www-data <container_name_for_koel> php artisan koel:sync
177-
```
80+
### Environment variables
17881

179-
### Populate the search indexes
180-
181-
If you were running a version of Koel prior to v5.0.2, the search mechanism has changed and needs a step to index songs, albums and artists. Run the following command:
82+
> [!IMPORTANT]
83+
> This list is not exhaustive. See [`.env.example`][koel-env-example] for a complete reference.
84+
85+
| Variable | Description |
86+
|---|---|
87+
| `SKIP_INIT` | If set, prevents the container from running `koel:init` on startup. |
88+
| `DB_CONNECTION` | `mysql`, `pgsql`, `sqlsrv`, or `sqlite-persistent`. |
89+
| `DB_HOST` | Hostname of the database container. Must be on the same Docker network. |
90+
| `DB_USERNAME` | Database username (default: `koel`). |
91+
| `DB_PASSWORD` | Database password. Must match the database container's configuration. |
92+
| `DB_DATABASE` | Database name (default: `koel`). |
93+
| `APP_KEY` | Base64-encoded key generated by `koel:init` or `key:generate`. |
94+
| `FORCE_HTTPS` | Set to `true` if using an HTTPS reverse proxy in front of Koel. |
95+
| `MEMORY_LIMIT` | Memory limit in MB for the scanning process. |
96+
| `LASTFM_API_KEY`, `LASTFM_API_SECRET` | Enables [Last.fm integration](https://docs.koel.dev/3rd-party.html#last-fm). |
97+
| `SPOTIFY_CLIENT_ID`, `SPOTIFY_CLIENT_SECRET` | Enables [Spotify integration](https://docs.koel.dev/3rd-party.html#spotify). |
98+
| `OPTIMIZE_CONFIG` | Preloads and optimizes configuration. Changes require a container restart. |
99+
100+
## Managing Music
101+
102+
Koel's init script installs a [scheduler](https://docs.koel.dev/cli-commands#command-scheduling) that scans `/music` daily. To trigger a manual scan:
182103

183104
```bash
184-
docker exec --user www-data <container_name_for_koel> php artisan koel:search:import
105+
docker exec --user www-data <koel_container> php artisan koel:sync
185106
```
186107

187-
For all new songs, the search index will be automatically populated by `php artisan koel:scan`. No need to run the `php artisan koel:search:import` again 🙂.
188-
189-
## Useful environment variables
190-
191-
> [!IMPORTANT]
192-
> This list is not exhaustive and may not be up-to-date. See [`.env.example`][koel-env-example] for a complete reference.
193-
194-
- `SKIP_INIT`: Prevents the container from automatically running the init script on startup.
195-
- `DB_CONNECTION`: `mysql` OR `pgsql` OR `sqlsrv` OR `sqlite-persistent`. Corresponds to the type of database being used with Koel.
196-
- `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.
197-
- `DB_USERNAME`: `koel`. If you change it, also change it in the database container.
198-
- `DB_PASSWORD`: The password credential matching `DB_USERNAME`. If you change it, also change it in the database container.
199-
- `DB_DATABASE`: `koel`. The database name for Koel. If you change it, also change it in the database container.
200-
- `APP_KEY`: A base64-encoded string, generated by `php artisan koel:init` or by `php artisan key:generate`.
201-
- `FORCE_HTTPS`: If set to `true`, all URLs redirects done by koel will use `https`. If you have set up a reverse-proxy in front of this container that supports `https`, set it to `true`.
202-
- `MEMORY_LIMIT`: The amount of memory in MB for the scanning process. Increase this value if `php artisan koel:scan` runs out of memory.
203-
- `LASTFM_API_KEY` and `LASTFM_API_SECRET`: Enables Last.fm integration. See https://docs.koel.dev/3rd-party.html#last-fm
204-
- `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET`: Enables Spotify integration. See https://docs.koel.dev/3rd-party.html#spotify
205-
- `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.
206-
207108
## Volumes
208109

209-
### /music
210-
211-
`/music` will contain the music library.
212-
213-
### /var/www/html/storage/search-indexes
214-
215-
`/var/www/html/storage/search-indexes` will contain the search indexes. Searching songs, albums and artists leverages this to provide results.
110+
| Path | Description |
111+
|---|---|
112+
| `/music` | Your music library. |
113+
| `/var/www/html/public/img/storage` | Uploaded images (album art, user avatars, etc.). |
114+
| `/var/www/html/storage/search-indexes` | Search indexes for songs, albums, and artists. |
216115

217116
## Ports
218117

219-
### 80
220-
221-
Only HTTP is provided. Consider setting up a reverse-proxy to provide HTTPS support.
118+
Only port **80** (HTTP) is exposed. Set up a reverse proxy for HTTPS support.
222119

223120
## Workdir
224121

225-
### /var/www/html
226-
227-
Apache's root directory. All koel files will be here. If you `exec` into the container, this will be your current directory.
122+
The container's working directory is `/var/www/html` (Apache's document root). All Koel files reside here.
228123

229124
## Local Development
230125

231-
Inside `Makefile` you'll find several commands that can aid during the local development of koel/docker. For example, to build and start the `dev` docker-composer stack, run `make start`.
126+
The `Makefile` contains several helper commands for local development. For example, to build and start the dev stack:
127+
128+
```bash
129+
make start
130+
```
232131

233132
## Help & Support
234133

235-
If you run into any issues, check the [Koel documentation][koel-doc] first.
134+
If you run into any issues, check the [Koel documentation][koel-doc] first.
236135
If you encounter a bug in Koel itself, open an issue in the [Koel repository][koel-repo].
237-
This repos issues are reserved for Docker-related questions and problems.
136+
This repo's issues are reserved for Docker-related questions and problems.
238137

239138
[koel-env-example]: https://github.com/koel/koel/blob/master/.env.example
240-
[koel-requirements]: https://docs.koel.dev/guide/getting-started#requirements
241-
[koel]: https://koel.dev/
139+
[Koel]: https://koel.dev/
242140
[koel-doc]: https://docs.koel.dev/
243141
[koel-repo]: https://github.com/koel/koel
244-
[mariadb]: https://hub.docker.com/r/mariadb/server
245142
[docker-compose]: https://docs.docker.com/compose/
246143

247144
[docker-pulls-badge]: <https://img.shields.io/docker/pulls/phanan/koel>

0 commit comments

Comments
 (0)