Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a docker image #10

Closed
SkinyMonkey opened this issue Dec 14, 2015 · 64 comments
Closed

Create a docker image #10

SkinyMonkey opened this issue Dec 14, 2015 · 64 comments

Comments

@SkinyMonkey
Copy link

I don't have experience with the PHP ecosystem so I might have some problem doing it but if you help me It should be easy/quick to do.

Contact me!

@sammcj
Copy link

sammcj commented Dec 14, 2015

+1

3 similar comments
@reyman
Copy link

reyman commented Dec 14, 2015

👍

@risq
Copy link

risq commented Dec 14, 2015

👍

@eladg
Copy link

eladg commented Dec 14, 2015

+1

@n2o
Copy link

n2o commented Dec 14, 2015

A docker container would be awesome!

@sg-s
Copy link

sg-s commented Dec 14, 2015

+1

@ColmHally
Copy link

I like this project and would be happy to contribute a Docker image later tonight, unless someone else has started already?

@LuRsT
Copy link

LuRsT commented Dec 14, 2015

@ColmHally I was planning on doing it too, but since you stepped up first, go ahead :)

@ColmHally
Copy link

@LuRsT ha! Ok - when I've got something, would you mind reviewing? I'll probably add a docker-compose.yml file as well so the mysql dependency is in a separate container.

@LuRsT
Copy link

LuRsT commented Dec 14, 2015

@ColmHally Sounds good! Yes, using docker compose is a good idea :)

@NamPNQ
Copy link
Contributor

NamPNQ commented Dec 14, 2015

I'm current doing it 💃

@ColmHally
Copy link

@NamPNQ cool!

@w0rd-driven
Copy link

Since this is a laravel project you can use homestead, the preconfigured vagrant environment. Basic docs are here: http://laravel.com/docs/5.1/homestead.

I'd personally choose the Per Project Installation (http://laravel.com/docs/5.1/homestead#per-project-installation), run homestead make, and include the definitions in the repo.

I know this is specifically a docker thread but if you have no preference between docker and vagrant, the homestead VM is already setup to host laravel projects.

@LuRsT
Copy link

LuRsT commented Dec 14, 2015

@w0rd-driven they both have their advantages and disadvantages, the project could support both if @phanan accepts.

@wmartins
Copy link

+1

2 similar comments
@dellingera
Copy link

+1

@mpgirro
Copy link

mpgirro commented Dec 14, 2015

+1

@Lusitaniae
Copy link

sounds interesting, can I see it as well?
Maybe I can give a hand

@telemakhos
Copy link

+1

3 similar comments
@samliu
Copy link

samliu commented Dec 14, 2015

+1

@extensionsapp
Copy link

+1

@kodeartisan
Copy link

+1

@hernandanielg
Copy link

I would be happy to create a Vagrant and a docker image, but Idk if we will end doing the same thing at the same time... Someone could help me because I'm new here 🚶

@phanan
Copy link
Member

phanan commented Dec 15, 2015

image

@NamPNQ
Copy link
Contributor

NamPNQ commented Dec 15, 2015

Hi friends,
I create branch for docker in here: https://github.com/NamPNQ/koel/tree/feature-docker
How to install via docker

$ cp .env.example .env
$ vi .env

Config admin info and db info

DB_HOST=db
DB_DATABASE=koel
DB_USERNAME=root
DB_PASSWORD=secret

Run docker

$ pip install docker-compose
$ docker-compose build
$ docker-compose run web php artisan migrate --force
$ docker-compose run web php artisan db:seed --force

It's done,..but i get error in larevel, i don't familar with larevel to solve it, anyone can help me to continue

@phanan
Copy link
Member

phanan commented Dec 15, 2015

@NamPNQ You need to run php artisan key:generate to generate a key. But scratch that, @mattstauffer has added a php artisan init to cover key:generate migrate and db:seed. Please refer to the updated wiki.

@NamPNQ
Copy link
Contributor

NamPNQ commented Dec 15, 2015

@phanan: I got my mistake, I set .env to enviroment, and when run app it not get in .env, it get in enviroment 💃

@sammcj
Copy link

sammcj commented Dec 15, 2015

Thanks @NamPNQ , any chance you could swap out Apache for Nginx?
Generally Nginx is faster, lighter weight and more secure than Apache these days.

@NamPNQ
Copy link
Contributor

NamPNQ commented Dec 15, 2015

@samliu Waiting #7 closed 👍

@phanan
Copy link
Member

phanan commented Dec 15, 2015

RUN su root
RUN composer install
RUN chsh -s /usr/sbin/nologin www-data
RUN php artisan key:generate && php artisan config:clear

I don't think this is proper.

  • Composer should be run by www-data
  • php artisan key:generate should be replaced by php artisan init
  • php artisan config:clear why do we need this?

@phanan
Copy link
Member

phanan commented Dec 16, 2015

@etopian This looks great!

@Cotix
Copy link

Cotix commented Dec 17, 2015

@etopian Why not include the database in the image aswell?

@etopian
Copy link

etopian commented Dec 17, 2015

@Cotix I run 25 websites on my server. i don't want to run 25 db instances. just use any mysql/mariadb database image. i bind port 3306 to the first IP in Docker's subnet range, 172.17.0.1, so it's accessible to all containers. it's trivial to add an db to the container though, just fork and add it.

@SkinyMonkey
Copy link
Author

@Cotix it's generally a bad practice in docker, if you lose your container you lose your data.

@etopian nice one, why didn't you use a link instead?

@etopian
Copy link

etopian commented Dec 18, 2015

@SkinyMonkey don't like the concept of strongly coupled things, if you want to upgrade your database how do you do that with 25 sites linked to the db container. docker says you should use an ambassador container, but that just seems like too much complexity. my way of doing it is nice and simple and lets me upgrade the database container anytime i want. i mount the database data dir from the host so that never goes away.

@SkinyMonkey
Copy link
Author

Mmh, in this particular context I don't imagine people launching 25 instance of koei but ok ;)

@etopian
Copy link

etopian commented Dec 18, 2015

@SkinyMonkey btw if you want to link a container you can do it with this image.. just specify the link as the DB_HOST... i.e. -v DB_HOST=mysql

@kevincaradant
Copy link

Hi everyone

Maybe someone will be able to help me about docker. I try to create a docker image for arm support. It's the first time, i look docker so i'm currently learning , i look the etopian Dockerfile and NamPNQ Dockerfile also. For the moment, i stay on Apache and mysql. I want to connect my docker image (koel) with my dokcer image (mysql) . Is it a good practice or not ? .

For my docker koel , this is my first Dockerfile version :

FROM ubuntu:latest
MAINTAINER Kevin CARADANT <caradant@gmail.com>
LABEL   type="web site" \
        architecture="ARMv7"

RUN apt-get update \
    && apt-get install aufs-tools apache2 net-tools apt-utils php5-mysql python dialog php5 g++ git curl automake build-essential bash less vim ca-certificates zlibc zlib1g zlib1g-dev -y \
    && curl -sL https://deb.nodesource.com/setup_5.x | bash - \
    && apt-get install -y nodejs \
    && apt-get clean \
    && npm install -g bower gulp \
    && adduser --gecos '' --disabled-password nginx \
    && chown -R nginx /var/www/html \
    && cd /var/www/html/\

RUN cd /var/www/html/ \
    && su nginx -c 'git config --global url."https://".insteadOf git://' \
    && su nginx -c "git clone https://github.com/phanan/koel \
    && cd koel \
    && npm install"

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
    && cd /var/www/html/koel && composer install

ENV TERM="xterm" \
    DB_HOST="172.17.0.1" \
    DB_DATABASE="koel" \
    DB_USERNAME="koel-db-user"\
    DB_PASSWORD="koel-pass"\
    ADMIN_EMAIL="myadress@gmail.com"\
    ADMIN_NAME="kevin"\
    ADMIN_PASSWORD="kevin"\
    APP_DEBUG=false\
    AP_ENV=production

VOLUME ["/DATA/music"]

RUN rm -rf /var/cache/apt/*
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /home/nginx/.npm /root/.npm

COPY .env /var/www/html/

RUN a2enmod rewrite
RUN cd /var/www/html/koel && php artisan init
RUN /var/www/html/koel && php artisan serve --host 0.0.0.0

My .env file :

APP_ENV=local
APP_DEBUG=true
APP_KEY=JIOjhioh4iohou7888

# Username and password for the initial admin account
# This info will be populated into the database during `php artisan db:seed`
# After that, it can (and should) be removed from this .env file
ADMIN_EMAIL=$ADMIN_EMAIL
ADMIN_NAME=$ADMIN_NAME
ADMIN_PASSWORD=$ADMIN_PASSWORD

# The maximum scan time, in seconds. Increase this if you have a huge library.
APP_MAX_SCAN_TIME=600

# The streaming method. 
# Can be either 'php' (default), 'x-sendfile', or 'x-accel-redirect'
# See https://github.com/phanan/koel/wiki#streaming-music for more information.
STREAMING_METHOD=php

DB_HOST=$DB_HOST
DB_DATABASE=$DB_DATABASE
DB_USERNAME=$DB_USERNAME
DB_PASSWORD=$DB_PASSWORD

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

image
So how to know the IP from mysql:5.6 image ? How to link this database with koel image ?

After my second docker image is just the mysql docker that i have init like this :

sudo docker run -i -t -e MYSQL_ROOT_PASSWORD=my_pass mysql:5.6

docker exec -it 360b4e5b246f bash

and write this :
mysql> CREATE DATABASE koel DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

mysql>CREATE USER 'koel-db-user'@'localhost' IDENTIFIED BY 'koel-pass';

mysql> GRANT ALL PRIVILEGES ON koel.* TO 'koel-db-user'@'localhost' WITH GRANT OPTION;

PS: In this case i used an image no arm because i lost all my last day to build just 4 times, that ask so much time and RAM ... so when it's good with intel64bits , i will adapt for my arm version :).

Thank you for your help guys, i know it's not your first task in your list but that will be very nice for me ;)

@CedricGatay
Copy link

@kevincaradant Hi,
I think your image contains unnecessary things (nginx/apache but you're running it with php).
For a x86 working image, take a look at my repository (https://github.com/CedricGatay/docker-koel) and use the docker-compose file to be up and running.
But as you're running under arm, I guess you will need to change the FROM for my dockerfile as well as pick a mysql/mariadb compatible image.

@kevincaradant
Copy link

Thank you @CedricGatay , i like your repo simple. It's very interesting.

So i replace that :

RUN apt-get update \ && apt-get install aufs-tools apache2 net-tools apt-utils php5-mysql python dialog php5 g++ git curl automake build-essential bash less vim ca-certificates zlibc zlib1g zlib1g-dev -y \

By that :

RUN apt-get update \ && apt-get -y -q install aufs-tools net-tools apt-utils python bash g++ git curl automake php5 dialog php5-cli php5-mysql git curl build-essential\

I deleted apache and user nginx.
My new Dockerfile very silimar with yours ^^ :

FROM ubuntu:latest
MAINTAINER Kevin CARADANT <kevin.caradant@gmail.com>

LABEL   type="Site Web" \
        architecture="ARMv7"

RUN apt-get update \
    && apt-get install aufs-tools net-tools apt-utils python bash g++ git curl automake php5 php5-cli php5-mysql git curl build-essential -y \
    && curl -sL https://deb.nodesource.com/setup_5.x | bash - \
    && apt-get install -y nodejs \
    && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
    && apt-get clean \
    && npm install -g bower gulp \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN groupadd -r koel -g 1000 \
    && useradd -u 1000 -r -g koel -d /app -s /sbin/nologin -c "Docker image user" koel\ 
    && mkdir -p /app \
    && chown -R koel:koel /app

EXPOSE 8000

USER koel

WORKDIR /app

RUN git config --global url."https://".insteadOf git:// \
    &&  git clone https://github.com/phanan/koel \
    && cd koel \
    && composer install

WORKDIR /app/koel

VOLUME ["/DATA/music"]


COPY env .env
COPY run.sh run.sh

RUN rm -rf /var/cache/apt/*
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /home/nginx/.npm /root/.npm

USER root
RUN chown -R koel:koel /app

USER koel
CMD ["/app/koel/run.sh"] 

After i see, you use something that i didn't understand before "docker-compose" .

I get yours but in "links" you have db:db . What is it ? i replace by what ?

After if i understand, i have to realize this :

docker build -i -t my_koel_arm .
that execute my Dockerfile that i defined

Then :

docker-compose up -d db; sleep 60; docker-compose up -d app; i don't understand option and what replace. what is the flag "-d" , i didn't see in the document docker-compose. :/. is it this , which link mysql image with koel image ?

Thank you for all after that , a lot of things will be more clear for me :D

@CedricGatay
Copy link

@kevincaradant I think you need to read more of docker documentation. In fact the docker link feature is used to link container. My db:db line does the link automatically between my db service (_:db) as a db host (db:_) when my app container is ran.

With compose you don't need to run your docker file manually, but you only have to run via compose (the -d flag makes the container go to the background).

To use the repository I gave you, you only need to symlink your music to the proper folder and everything should be working (perhaps some improvements are possible by using apache or nginx instead of php though)

@kevincaradant
Copy link

ohh oki thank you for this information , i'm going to learn more about this subject, , i ask you, just a last question; I'm trying to use your repo . But i get this question with your command (maybe i'm stupid but i think, you don't give me the solution about this ) :

docker-compose up -d db; sleep 60; docker-compose up -d app; 

image

What need to mention ? Thank you

Edit : it was just a problem of rights ... sudo fix it.... sorry for this useless question

@CedricGatay
Copy link

@kevincaradant add your user to the docker group (sudo usermod -aG docker $(whoami)) to get rid of sudoing every docker command.

I updated my docker image to use php7 with apache2 (cc @phanan). Feel free to take a look at it.

@kevincaradant
Copy link

yep i watch your repo very often, i see your update but i was still to understand your first commit :) , i will check that tomorrow now i know the base of docker. Thank you @CedricGatay :) and ok for the command about rights ;)

@jommgoncalves
Copy link

+1

For now, I only want test it. The list of dependencies is incredible!

@kevincaradant
Copy link

i think i'm not so far to success, but in the moment that does not work... this is my repo inspired by existing repo on docker : https://github.com/kevincaradant/armhf_docker_koel/tree/dev , even the readme is not changed ^^, . It's for intel but i can easily trnsform it for arm that why i like my repo. If someone can help me about config because i get this error in : /DATA/htdocs/storage/logs/laravel.log

[2015-12-24 02:36:11] local.ERROR: exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' in /DATA/htdocs/vendor/laravel/framework/src/Il$
Stack trace:
#0 /DATA/htdocs/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(55): PDO->__construct('mysql:host=;dbn...', '', '', Array)
#1 /DATA/htdocs/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(22): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=;dbn...', Array, Array)
#2 /DATA/htdocs/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(60): Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#3 /

i don't know what can i change . But when i see that : mysql:host=;dbn that seem let to think that the variables are unknown inside the docker no ? thank you very much :) and sorry to invade the thread with my problem ;)

@Qeole
Copy link

Qeole commented Jan 17, 2016

Hi there!
Just in case it could help someone, I run @etopian's koel Docker image and wrote a tutorial on the steps I executed to make it work. Available there: https://blog.qoba.lt/koel_with_docker.html

@jee-r
Copy link

jee-r commented Jan 18, 2016

Thx @Qeole for this tuto, Thx @phanan for koel and @etopian for the dockerfile.

What about the lastfm feature ? is this in the todo-list

@etopian
Copy link

etopian commented Jan 18, 2016

@Qeole your page has been referenced by my Docker image. Thanks for the writeup.

@NamPNQ
Copy link
Contributor

NamPNQ commented Jan 18, 2016

@Qeole try using docker compose for simple setup :D

@Qeole
Copy link

Qeole commented Jan 18, 2016

@NamPNQ Thanks, I'll have a look at it!
@etopian that's neat! Thanks

@phanan
Copy link
Member

phanan commented Jan 31, 2016

I guess any of you can come up with a custom docker now, no need for an "official" kind of. Closing this to clean the list.

@maxengel
Copy link

@etopian Thanks for creating this! Everything goes fine, but upon first run, the media path in "Settings" is empty, despite setting it when getting the container setup. I can change it to /DATA/music and can confirm via the CLI that it sees the music, but scanning doesn't seem to work. Any ideas?

nklido pushed a commit to nklido/koel that referenced this issue Jan 7, 2020
Bump handlebars from 4.0.11 to 4.1.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests