diff --git a/DOCKER.md b/DOCKER.md index 77d3fae..c06d083 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -115,6 +115,17 @@ docker run --name apache --restart=always \ -d pluie/alpine-apache ``` +### Symfony +``` +cd /home/dev/docker +docker run --name symfony --restart=always \ +--net home0 -h symfony.docker --ip 172.22.0.7 --link=mysql:db \ +-e HTTP_SERVER_NAME=symfony \ +-e SYMFONY_VERSION=2.8 \ +-v $(pwd)/repo/myapp:/app \ +-d pluie/alpine-symfony +``` + #### Wordpress ``` cd /home/dev/docker diff --git a/README.md b/README.md index 6ac9130..d8dd097 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,11 @@ various based images for Docker ## Available Images -- [pluie/alpine][2] ( < 10 MB ) Alpine/3.4 -- [pluie/alpine-apache][3] ( ~ 50 MB ) Apache/2.4.23 Php/5.6.24 -- [pluie/alpine-mysql][4] ( ~172 MB ) Mysql/5.5.47 ( MariaDB ) +- [pluie/alpine][2] ( < 10 MB ) Alpine/3.4 + - [pluie/alpine-apache][3] ( ~ 50 MB ) Apache/2.4.23 Php/5.6.24 + - [image pluie/alpine-symfony][6] ( ~ 81 MB ) + - [pluie/alpine-mysql][4] ( ~172 MB ) Mysql/5.5.47 ( MariaDB ) + - [docker tips][5] ## Base Image Structure @@ -22,7 +24,7 @@ project/ | |-- pre-init.d/ # deployed in /scripts on target container | | # launch on docker container running process - | |-- 50-example.sh + | |-- 50-builder.sh | |-- build # build docker image : ./build [TAG] |-- common.sh # don't modify - sourced by main.sh to execute pre-init.d scripts first @@ -74,3 +76,4 @@ you can keep same __build__ script in any project [3]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-mysql [4]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-apache [5]: https://github.com/pluie-org/docker-images/blob/master/DOCKER.md + [6]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-symfony diff --git a/pluie/alpine-apache/Dockerfile b/pluie/alpine-apache/Dockerfile index 0cd9251..391fcea 100644 --- a/pluie/alpine-apache/Dockerfile +++ b/pluie/alpine-apache/Dockerfile @@ -10,6 +10,8 @@ ADD files.tar /scripts ENV SHENV_NAME=Apache \ SHENV_COLOR=67 \ HTTP_SERVER_NAME=docker-site.dev \ + WWW_DIR=www \ + WWW_INDEX=index \ FIX_OWNERSHIP=1 \ TZ=Europe/Paris diff --git a/pluie/alpine-apache/README.md b/pluie/alpine-apache/README.md index 958ce70..07966a1 100644 --- a/pluie/alpine-apache/README.md +++ b/pluie/alpine-apache/README.md @@ -3,6 +3,7 @@ - [index][1] - [image pluie/alpine][2] - [image pluie/alpine-mysql][3] +- [image pluie/alpine-symfony][6] - [docker tips][5] Extend pluie/alpine with __apache 2.4.23__ and __php 5.6.24__ @@ -17,17 +18,34 @@ Extend pluie/alpine with __apache 2.4.23__ and __php 5.6.24__ - image ~ 50 MB +## ENV variables + +``` + HTTP_SERVER_NAME=apache.docker # apache ServerName + WWW_DIR=www # DocumentRoot relative to volume + WWW_INDEX=index.php # DirectoryIndex + FIX_OWNERSHIP=1 # +``` + +### Inherit ENV variables + +``` + SHENV_CTX=LOCAL # LOCAL|INT|PROD change context bg color + SHENV_NAME=Apache # container name + SHENV_COLOR=67 # ANSI EXTENDED COLOR CODE + TZ=Europe/Paris # TIMEZONE +``` ## Image Volumes __/app__ directory is a docker volume bind to your app project (silex/symfony etc) -__/app/www/__ is the documentRoot. +__/app/$WWW_DIR__ is the documentRoot. put only your entry point and static files to the documentRoot directory, no your app sources (__/app__ directory is design for this). __/app/vhost__ is your app vhost configuration file (with a serverName directive). -by default it use the apache rewrite module to redirect all uri to the unique entry point index.php +by default it use the apache rewrite module to redirect all uri to entry point $WWW_INDEX ``` /app/ # your application directory @@ -65,3 +83,4 @@ $ docker exec -it apache "httpd -h" [3]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-mysql [4]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-apache [5]: https://github.com/pluie-org/docker-images/blob/master/DOCKER.md + [6]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-symfony diff --git a/pluie/alpine-apache/files.tar b/pluie/alpine-apache/files.tar index 281fac0..fb86f55 100644 Binary files a/pluie/alpine-apache/files.tar and b/pluie/alpine-apache/files.tar differ diff --git a/pluie/alpine-apache/install.d/50-fix-apache.sh b/pluie/alpine-apache/install.d/50-fix-apache.sh index d6ebbed..ed7a61a 100755 --- a/pluie/alpine-apache/install.d/50-fix-apache.sh +++ b/pluie/alpine-apache/install.d/50-fix-apache.sh @@ -2,13 +2,15 @@ # @app pluie/alpine-apache # @author a-Sansara https://git.pluie.org/pluie/docker-images -mkdir -p /app/www -chown -R 1000:apache /app/www +mkdir -p /app/$WWW_DIR +chown -R 1000:apache /app/$WWW_DIR chmod -R 755 /scripts/pre-init.d mkdir -p /run/apache2 chown apache:apache /run/apache2 -sed -i 's#^DocumentRoot ".*#DocumentRoot "/app/www"#g' /etc/apache2/httpd.conf +tmpsed='s#^DocumentRoot ".*#DocumentRoot "/app/'$WWW_DIR'"#g' +sed -i "$tmpsed" /etc/apache2/httpd.conf sed -i 's#AllowOverride none#AllowOverride All#' /etc/apache2/httpd.conf sed -i 's#\#LoadModule rewrite_module modules/mod_rewrite.so#LoadModule rewrite_module modules/mod_rewrite.so#' /etc/apache2/httpd.conf sed -ir 's/expose_php = On/expose_php = Off/' /etc/php5/php.ini echo -e "\nIncludeOptional /app/vhost" >> /etc/apache2/httpd.conf +unset tmpsed diff --git a/pluie/alpine-apache/pre-init.d/10-apache.sh b/pluie/alpine-apache/pre-init.d/10-apache.sh index 625703a..aa532e8 100755 --- a/pluie/alpine-apache/pre-init.d/10-apache.sh +++ b/pluie/alpine-apache/pre-init.d/10-apache.sh @@ -2,8 +2,8 @@ # @app pluie/alpine-apache # @author a-Sansara https://git.pluie.org/pluie/docker-images -if [ ! -z "$FIX_OWNERSHIP" ] && [ "$FIX_OWNERSHIP" -eq 1 ]; then - chown -R 1000:apache /app/www +if [ ! -z "$FIX_OWNERSHIP" ] && [ "$FIX_OWNERSHIP" -eq 1 ] && [ -d /app/$WWW_DIR ]; then + chown -R 1000:apache /app/$WWW_DIR fi touch /var/log/apache2/error.log diff --git a/pluie/alpine-apache/pre-init.d/10-vhost.sh b/pluie/alpine-apache/pre-init.d/10-vhost.sh index 38de362..931695a 100755 --- a/pluie/alpine-apache/pre-init.d/10-vhost.sh +++ b/pluie/alpine-apache/pre-init.d/10-vhost.sh @@ -6,15 +6,15 @@ if [ ! -z "/app/vhost" ]; then cat < "/app/vhost" ServerName $HTTP_SERVER_NAME - + AllowOverride None Require all granted - DirectoryIndex index.php + DirectoryIndex $WWW_INDEX Options -MultiViews +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^ index.php [QSA,L] + RewriteRule ^ $WWW_INDEX [QSA,L] diff --git a/pluie/alpine-mysql/README.md b/pluie/alpine-mysql/README.md index f47c6ef..f7652d6 100644 --- a/pluie/alpine-mysql/README.md +++ b/pluie/alpine-mysql/README.md @@ -3,6 +3,7 @@ - [index][1] - [image pluie/alpine][2] - [image pluie/alpine-apache][4] +- [image pluie/alpine-symfony][6] - [docker tips][5] Extend pluie/alpine with mysql (mariadb) 5.5.47 @@ -129,3 +130,4 @@ docker run --name mycontainer --link mysql:db ... [3]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-mysql [4]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-apache [5]: https://github.com/pluie-org/docker-images/blob/master/DOCKER.md + [6]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-symfony diff --git a/pluie/alpine-symfony/Dockerfile b/pluie/alpine-symfony/Dockerfile new file mode 100644 index 0000000..dc49bae --- /dev/null +++ b/pluie/alpine-symfony/Dockerfile @@ -0,0 +1,19 @@ +# @app pluie/alpine-symfony +# @author a-Sansara https://git.pluie.org/pluie/docker-images + +FROM pluie/alpine-apache + +MAINTAINER a-Sansara https://github.com/a-sansara + +ADD files.tar /scripts + +ENV SHENV_NAME=Symfony \ + SHENV_COLOR=33 \ + HTTP_SERVER_NAME=symfony.docker \ + WWW_DIR=web \ + WWW_INDEX=app.php \ + SYMFONY_VERSION=3.1 + +EXPOSE 80 + +RUN bash /scripts/install.sh diff --git a/pluie/alpine-symfony/README.md b/pluie/alpine-symfony/README.md new file mode 100644 index 0000000..ff2a5e2 --- /dev/null +++ b/pluie/alpine-symfony/README.md @@ -0,0 +1,74 @@ +# pluie/alpine-symfony + +- [index][1] +- [image pluie/alpine][2] +- [image pluie/alpine-mysql][3] +- [image pluie/alpine-apache][4] +- [image pluie/alpine-symfony][6] +- [docker tips][5] + +Extend pluie/alpine-apache. +if __/app/$WWW_DIR__ does not exits then __pluie/alpine-symfony__ install +the symfony framework with $SYMFONY_VERSION version on the /app directory + +## Image Size + +- image ~ 81 MB + +## ENV variables + +``` + SYMFONY_VERSION=3.1 # symfony version +``` + +### Inherit ENV variables + +``` + HTTP_SERVER_NAME=symfony.docker # apache ServerName + WWW_DIR=web # DocumentRoot relative to volume + WWW_INDEX=app.php # DirectoryIndex + SHENV_CTX=LOCAL # LOCAL|INT|PROD change context bg color + SHENV_NAME=symfony # container name + SHENV_COLOR=33 # ANSI EXTENDED COLOR CODE + FIX_OWNERSHIP=1 + TZ=Europe/Paris # TIMEZONE +``` + +## Image Volumes + +__/app__ directory is a docker volume bind to your symfony project + + +## Image Usage + +chdir to your project directory +``` +$ docker run --name symfony -it --link=mysql:db1 -v $(pwd):/app pluie/alpine-symfony +``` +or +``` +$ docker run --name symfony -it --link=mysql:db1 -e HTTP_SERVER_NAME=yourServerName -v $(pwd):/app pluie/alpine-symfony +``` + +## Connect to container + +``` +$ docker exec -it symfony bash +``` + +## Controling http server + +``` +$ docker exec -it apache "httpd -k restart" +``` +for more commands : +``` +$ docker exec -it apache "httpd -h" +``` + + [1]: https://github.com/pluie-org/docker-images + [2]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine + [3]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-mysql + [4]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-apache + [5]: https://github.com/pluie-org/docker-images/blob/master/DOCKER.md + [6]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-symfony diff --git a/pluie/alpine-symfony/build b/pluie/alpine-symfony/build new file mode 100755 index 0000000..09b3da8 --- /dev/null +++ b/pluie/alpine-symfony/build @@ -0,0 +1,22 @@ +#!/bin/bash +# @app pluie/alpine-apache +# @author a-Sansara https://git.pluie.org/pluie/docker-images + + Ctitle="\033[1;38;5;15;1;48;5;30m" + Citem="\033[1;38;5;36m" + Coff="\033[m" + DOCKDIR=$(dirname "$(readlink -f ${BASH_SOURCE[0]})") +DOCKBUILD=$(basename $DOCKDIR) + DOCKREPO=$(basename $(dirname $DOCKDIR)) + DOCKTAG=${1:-"latest"} + TMPPWD=$(pwd) + indent=" " +cd $DOCKDIR +echo -e "\n ${Ctitle} Preparing files : ${Coff}${Citem}\n" + +tar -cvf files.tar *.sh pre-init.d/ install.d/ | sed "s/^/${indent}↠ /" + +echo -e "\n ${Ctitle} Proceed Dockerfile build : ${Coff}\n +" +docker build --force-rm -t ${DOCKREPO}/${DOCKBUILD}:${DOCKTAG} . | sed "s/^/${indent}/" +cd $TMPPWD diff --git a/pluie/alpine-symfony/files.tar b/pluie/alpine-symfony/files.tar new file mode 100644 index 0000000..9fe64a4 Binary files /dev/null and b/pluie/alpine-symfony/files.tar differ diff --git a/pluie/alpine-symfony/install.d/10-symfony.sh b/pluie/alpine-symfony/install.d/10-symfony.sh new file mode 100755 index 0000000..c1ff563 --- /dev/null +++ b/pluie/alpine-symfony/install.d/10-symfony.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# @app pluie/alpine-symfony +# @author a-Sansara https://git.pluie.org/pluie/docker-images + +apk -U add php5-iconv php5-intl php5-posix +curl -LsS https://symfony.com/installer -o /usr/bin/symfony +chmod +x /usr/bin/symfony diff --git a/pluie/alpine-symfony/pre-init.d/10-symfony.sh b/pluie/alpine-symfony/pre-init.d/10-symfony.sh new file mode 100644 index 0000000..308e947 --- /dev/null +++ b/pluie/alpine-symfony/pre-init.d/10-symfony.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# @app pluie/alpine-symfony +# @author a-Sansara https://git.pluie.org/pluie/docker-images + + +if [ ! -d /app/$WWW_DIR ]; then + cd /tmp + mkdir $WWW_DIR + symfony new app $SYMFONY_VERSION + mv app/* /app/ + chown -R 1000:apache /app/ + chmod -R g+w /app +fi diff --git a/pluie/alpine/README.md b/pluie/alpine/README.md index 4127f55..9dbdf17 100644 --- a/pluie/alpine/README.md +++ b/pluie/alpine/README.md @@ -3,6 +3,7 @@ - [index][1] - [image pluie/alpine-mysql][3] - [image pluie/alpine-apache][4] +- [image pluie/alpine-symfony][6] - [docker tips][5] This Image provide a Linux Alpine distribution with : @@ -15,6 +16,11 @@ Base image : [alpine:3.4] (https://hub.docker.com/_/alpine/) This project come with a structure to facilitate further images (like pluie/alpine-apache & pluie/alpine-mysql) +__note :__ wget ssl issue + +apk add ca-certificates wget && update-ca-certificates + + ## Image Size - very small image < 10 MB @@ -39,7 +45,7 @@ project/ | |-- pre-init.d/ # deployed in /scripts on target container | | # launch on docker container running process - | |-- 50-example.sh + | |-- 50-builder.sh | |-- build # build docker image : ./build [TAG] |-- common.sh # don't modify - sourced by main.sh to execute pre-init.d scripts first @@ -89,3 +95,4 @@ VOLUME /app [3]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-mysql [4]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-apache [5]: https://github.com/pluie-org/docker-images/blob/master/DOCKER.md + [6]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-symfony