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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore .env file (like mariadb.env and database-info.env) to avoid accidental commit of personnal data
*.env
80 changes: 60 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,86 @@ This is the Git repository of the official Docker image for [Sonerezh](https://w

**WARNING**: the Docker image for Sonerezh is still under development. Some functionnality are broken like email notifications for example.

# How to build this image
## How to build this image

Simply clone this repository and use `docker build`:

```sh
$ git clone --master https://github.com/Sonerezh/docker.git
$ cd docker/nginx
$ docker build --tag sonerezh .
$> git clone --master https://github.com/Sonerezh/docker
$> cd docker/nginx
$> docker build --tag sonerezh .
```
# How to use this image

## Manually
## How to use this image

### Manually

You can configure your Sonerezh instance manually. First you will need to run `mysql` or `mariadb` container:

```sh
$ docker run --name sonerezh-db --env MYSQL_ROOT_PASSWORD=changeme \
--env MYSQL_USER=sonerezh \
--env MYSQL_PASSWORD=changemetoo \
--env MYSQL_DATABASE=sonerezh \
--volume /path/to/mysql/data:/var/lib/mysql \
--detach mariadb
$> docker run --name sonerezh-db --env MYSQL_ROOT_PASSWORD=changeme \
--env MYSQL_USER=sonerezh \
--env MYSQL_PASSWORD=changemetoo \
--env MYSQL_DATABASE=sonerezh \
--volume /path/to/mysql/data:/var/lib/mysql \
--detach \
mariadb
```

And then run Sonerezh container:

```sh
$ docker run --name sonerezh-app --link sonerezh-db:sonerezh-db \
--volume /path/to/music:/music \
--volume /path/to/thumbnails:/thumbnails \
--detach --publish 8080:80 \
sonerezh/sonerezh:latest
$> docker run --name sonerezh-app --link sonerezh-db:sonerezh-db \
--volume /path/to/music:/music:ro \
--volume /path/to/thumbnails:/thumbnails \
--env MYSQL_USER=sonerezh \
--env MYSQL_PASSWORD=changemetoo \
--env MYSQL_DATABASE=sonerezh \
--detach --publish 8080:80 \
sonerezh/sonerezh
```

Your Sonerezh instance is available at http://127.0.0.1:8080 :) Make sure Sonerezh have read access to `/path/to/music` and read/write access to `/path/to/thumbnails`.

## Via docker-compose
### Via docker-compose

See example [docker-compose file](nginx/docker-compose.yml)

Next, you'll have to:

* create mariadb.env file (see [example](nginx/mariadb.env.example))
* create database-info.env file (see [example](nginx/database-info.env.example))
* update the docker-compose.yml file to set the link to your music in the volume definition (you may do the same for thumbnails)

```yaml
volumes:
- /path/to/your/music:/music:ro
```

* *optionnaly* update the exposed port

```yaml
ports:
- 8080:80
```

Your folder should looks like this:

```ls
-rw-r----- 1 root root 80 Aug 18 15:27 database-info.env
-rw-r--r-- 1 root root 729 Aug 18 15:29 docker-compose.yml
-rw-r----- 1 root root 57 Aug 18 15:27 mariadb.env
```

Then, all you can launch the containers:

```sh
$> pwd
/path/to/your/folder/sonerezh
$> docker-compose up -d
```

Coming soon
## Contributing

# Contributing
You are invited to contribute new features, fixes, or update, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.
Before you start to code, we recommend discussing your plans through a [GitHub issue](https://github.com/Sonerezh/sonerezh/issues), especially for more ambitious contributions.
7 changes: 1 addition & 6 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
supervisor

# Install Sonerezh
RUN git clone --branch 1.1.1 --depth 1 https://github.com/Sonerezh/sonerezh.git /usr/share/nginx/sonerezh && \
RUN git clone --branch 1.2.0 --depth 1 https://github.com/Sonerezh/sonerezh.git /usr/share/nginx/sonerezh && \
chown -R www-data: /usr/share/nginx/sonerezh && \
chmod 775 -R /usr/share/nginx/sonerezh

Expand All @@ -22,17 +22,12 @@ RUN mkdir /music && \
ln -s /usr/share/nginx/sonerezh/app/webroot/img/thumbnails /thumbnails && \
chown www-data: /music

VOLUME /music
VOLUME /thumbnails

# Copy image configuration
RUN rm -f /etc/nginx/sites-enabled/default
COPY database.php /usr/share/nginx/sonerezh/app/Config/database.php
COPY default /etc/nginx/sites-enabled/default
COPY supervisord.conf etc/supervisor/conf.d/supervisord.conf
COPY docker-entrypoint.sh /entrypoint.sh

EXPOSE 80

ENTRYPOINT ["/entrypoint.sh"]
CMD ["/usr/bin/supervisord"]
3 changes: 3 additions & 0 deletions nginx/database-info.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MYSQL_USER=sonerezh
MYSQL_PASSWORD=xxxxx
MYSQL_DATABASE=sonerezh
29 changes: 29 additions & 0 deletions nginx/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3'
services:
sonerezh-db:
image: mariadb
volumes:
- sonerezh-db-data:/var/lib/mysql
env_file:
- mariadb.env
- database-info.env
restart: always
app:
image: sonerezh/sonerezh:latest
depends_on:
- sonerezh-db
volumes:
- /path/to/your/music:/music:ro
- sonerezh-thumnails:/thumbnails
links:
- sonerezh-db:sonerezh-db
ports:
- 8080:80
env_file:
- database-info.env
restart: always
volumes:
sonerezh-db-data:
driver: local
sonerezh-thumnails:
driver: local
30 changes: 14 additions & 16 deletions nginx/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
#!/bin/bash
set -e

if [ -z "$SONEREZH_DB_PORT_3306_TCP_ADDR" ]; then
echo >&2 'error: missing required SONEREZH_DB_ENV_MYSQL_PASSWORD environment variable'
echo >&2 ' Did you forget to --link some-mysql-container:mysql?'
exit 1
fi
#
# - Take host from link name: MUST BE "sonerezh-db"
# - Take database name from our own environment variable "MYSQL_DATABASE" (default to sonerezh)
# - Same for database user "MYSQL_USER" (default to sonerezh)
# - Same for database password "MYSQL_PASSWORD" (but no default!)
#

if [ -z "$SONEREZH_DB_ENV_MYSQL_DATABASE" ]; then
echo >&2 'error: missing required SONEREZH_DB_ENV_MYSQL_PASSWORD environment variable'
echo >&2 ' Did you forget to --link some-mysql-container:mysql?'
if [ -z "$MYSQL_DATABASE" ]; then
echo >&2 'error: missing required MYSQL_DATABASE environment variable'
exit 1
fi

if [ -z "$SONEREZH_DB_ENV_MYSQL_USER" ]; then
if [ -z "$MYSQL_USER" ]; then
echo >&2 'error: missing required MYSQL_USER environment variable'
echo >&2 ' Did you forget to --link some-mysql-container:mysql?'
exit 1
fi

if [ -z "$SONEREZH_DB_ENV_MYSQL_PASSWORD" ]; then
if [ -z "$MYSQL_PASSWORD" ]; then
echo >&2 'error: missing required MYSQL_PASSWORD environment variable'
echo >&2 ' Did you forget to --link some-mysql-container:mysql?'
exit 1
fi

sed -i "s/SONEREZH_DB_PORT_3306_TCP_ADDR/${SONEREZH_DB_PORT_3306_TCP_ADDR}/" /usr/share/nginx/sonerezh/app/Config/database.php
sed -i "s/SONEREZH_DB_ENV_MYSQL_DATABASE/${SONEREZH_DB_ENV_MYSQL_DATABASE}/" /usr/share/nginx/sonerezh/app/Config/database.php
sed -i "s/SONEREZH_DB_ENV_MYSQL_USER/${SONEREZH_DB_ENV_MYSQL_USER}/" /usr/share/nginx/sonerezh/app/Config/database.php
sed -i "s/SONEREZH_DB_ENV_MYSQL_PASSWORD/${SONEREZH_DB_ENV_MYSQL_PASSWORD}/" /usr/share/nginx/sonerezh/app/Config/database.php
sed -i "s/SONEREZH_DB_PORT_3306_TCP_ADDR/sonerezh-db/" /usr/share/nginx/sonerezh/app/Config/database.php
sed -i "s/SONEREZH_DB_ENV_MYSQL_DATABASE/${MYSQL_DATABASE}/" /usr/share/nginx/sonerezh/app/Config/database.php
sed -i "s/SONEREZH_DB_ENV_MYSQL_USER/${MYSQL_USER}/" /usr/share/nginx/sonerezh/app/Config/database.php
sed -i "s/SONEREZH_DB_ENV_MYSQL_PASSWORD/${MYSQL_PASSWORD}/" /usr/share/nginx/sonerezh/app/Config/database.php
sed -i "s/define('DOCKER', false)/define('DOCKER', true)/" /usr/share/nginx/sonerezh/app/Config/bootstrap.php

exec "$@"
1 change: 1 addition & 0 deletions nginx/mariadb.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MYSQL_ROOT_PASSWORD=xxxxx