From 8ef37a71fb1b7fff28bc2f40992a4cef325b5aca Mon Sep 17 00:00:00 2001 From: Jack Fletcher Date: Mon, 15 Aug 2016 14:57:51 +0100 Subject: [PATCH 01/22] Remove hard-coded extensions from laravel.ini --- php-fpm/laravel.ini | 2 -- 1 file changed, 2 deletions(-) diff --git a/php-fpm/laravel.ini b/php-fpm/laravel.ini index dea3703b..486a2cab 100644 --- a/php-fpm/laravel.ini +++ b/php-fpm/laravel.ini @@ -1,8 +1,6 @@ date.timezone=UTC display_errors=Off log_errors=On -extension=mongodb.so -extension=zip.so ; Maximum amount of memory a script may consume (128MB) ; http://php.net/memory-limit From 3be9dee1c70c8eed07209891fdab27cde3af7dce Mon Sep 17 00:00:00 2001 From: Jack Fletcher Date: Mon, 15 Aug 2016 15:00:37 +0100 Subject: [PATCH 02/22] Update Dockerfile-70 --- php-fpm/Dockerfile-70 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index ed28119f..d99bf69f 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -45,7 +45,7 @@ MAINTAINER Mahmoud Zalt ARG INSTALL_XDEBUG=true ENV INSTALL_XDEBUG ${INSTALL_XDEBUG} RUN if [ ${INSTALL_XDEBUG} = true ]; then \ - # Install the xdebug extention + # Install the xdebug extension pecl install xdebug && \ docker-php-ext-enable xdebug \ ;fi @@ -57,8 +57,9 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ ARG INSTALL_MONGO=true ENV INSTALL_MONGO ${INSTALL_MONGO} RUN if [ ${INSTALL_MONGO} = true ]; then \ - # Install the mongodb extention - pecl install mongodb \ + # Install the mongodb extension + pecl install mongodb && \ + docker-php-ext-enable mongodb \ ;fi ##################################### @@ -68,8 +69,9 @@ RUN if [ ${INSTALL_MONGO} = true ]; then \ ARG INSTALL_ZIP_ARCHIVE=true ENV INSTALL_ZIP_ARCHIVE ${INSTALL_ZIP_ARCHIVE} RUN if [ ${INSTALL_ZIP_ARCHIVE} = true ]; then \ - # Install the zip extention - pecl install zip \ + # Install the zip extension + pecl install zip && \ + docker-php-ext-enable zip \ ;fi From 651430c7a9738c78d7ecc7bb6b039a6849acb6c8 Mon Sep 17 00:00:00 2001 From: Jack Fletcher Date: Mon, 15 Aug 2016 15:01:47 +0100 Subject: [PATCH 03/22] Update Dockerfile-56 --- php-fpm/Dockerfile-56 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/php-fpm/Dockerfile-56 b/php-fpm/Dockerfile-56 index fd881705..3ac78e6f 100644 --- a/php-fpm/Dockerfile-56 +++ b/php-fpm/Dockerfile-56 @@ -45,7 +45,7 @@ MAINTAINER Mahmoud Zalt ARG INSTALL_XDEBUG=true ENV INSTALL_XDEBUG ${INSTALL_XDEBUG} RUN if [ ${INSTALL_XDEBUG} = true ]; then \ - # Install the xdebug extention + # Install the xdebug extension pecl install xdebug && \ docker-php-ext-enable xdebug \ ;fi @@ -57,8 +57,9 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ ARG INSTALL_MONGO=true ENV INSTALL_MONGO ${INSTALL_MONGO} RUN if [ ${INSTALL_MONGO} = true ]; then \ - # Install the mongodb extention - pecl install mongodb \ + # Install the mongodb extension + pecl install mongodb && \ + docker-php-ext-enable mongodb \ ;fi ##################################### @@ -68,8 +69,9 @@ RUN if [ ${INSTALL_MONGO} = true ]; then \ ARG INSTALL_ZIP_ARCHIVE=true ENV INSTALL_ZIP_ARCHIVE ${INSTALL_ZIP_ARCHIVE} RUN if [ ${INSTALL_ZIP_ARCHIVE} = true ]; then \ - # Install the zip extention - pecl install zip \ + # Install the zip extension + pecl install zip && \ + docker-php-ext-enable zip \ ;fi From d8a4537efbab6a1181943cf4584f734b78e74317 Mon Sep 17 00:00:00 2001 From: larryeitel Date: Mon, 15 Aug 2016 08:59:29 -0600 Subject: [PATCH 04/22] Provided a way to Stop/Start php-fpm xdebug via bash script. --- README.md | 6 +- docker-compose.yml | 16 ++++++ php-fpm/Dockerfile-56 | 2 + php-fpm/Dockerfile-70 | 2 + php-fpm/xdebug_settings_only.ini | 21 +++++++ workspace/Dockerfile | 2 + workspace/xdebug_settings_only.ini | 20 +++++++ xdebugPhpFpm | 91 ++++++++++++++++++++++++++++++ 8 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 php-fpm/xdebug_settings_only.ini create mode 100644 workspace/xdebug_settings_only.ini create mode 100644 xdebugPhpFpm diff --git a/README.md b/README.md index 91710d6b..77e20266 100644 --- a/README.md +++ b/README.md @@ -957,8 +957,12 @@ Use `http://127.0.0.1` instead of `http://localhost` in your browser. Make sure the ports for the services that you are trying to run (80, 3306, etc.) are not being used already by other programs, such as a built in `apache`/`httpd` service or other development tools you have installed. +#### Stopping and Starting xdebug - +By default, if you have chosen to install xDebug, it will be running/enabled on startup. +- To stop xdebug in the `php-fpm` container, from your laradock folder, run: `./xdebugPhpFpm stop`. +- To start, run: `./xdebugPhpFpm start`. +- To see php -v, run: `./xdebugPhpFpm status`.
diff --git a/docker-compose.yml b/docker-compose.yml index a2313182..730849e2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,11 @@ services: - PGID=1000 volumes_from: - volumes_source + extra_hosts: + # IMPORTANT: Replace with your Docker Host IP + # this will be appended to /etc/hosts + # Note that this IP can perhaps be better injected via .env + - "dockerhost:10.0.75.1" tty: true ### PHP-FPM Container ####################################### @@ -34,6 +39,17 @@ services: - "9000" links: - workspace + extra_hosts: + # IMPORTANT: Replace with your Docker Host IP + # this will be appended to /etc/hosts + # Note that this IP can perhaps be better injected via .env + - "dockerhost:10.0.75.1" + environment: + # IMPORTANT: You must have a Remote Interpreter entry matching this name + # In settings, search for interpreter... + # PHP > Languages & Frameworks > PHP > Interpreter > click on [...] + # Need to have a Remote Interpreter named 'laravel' + - PHP_IDE_CONFIG="serverName=laravel" ### Nginx Server Container ################################## diff --git a/php-fpm/Dockerfile-56 b/php-fpm/Dockerfile-56 index 3ac78e6f..076fea08 100644 --- a/php-fpm/Dockerfile-56 +++ b/php-fpm/Dockerfile-56 @@ -49,6 +49,8 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ pecl install xdebug && \ docker-php-ext-enable xdebug \ ;fi +# ADD for REMOTE debugging +COPY ./xdebug_settings_only.ini /usr/local/etc/php/conf.d/xdebug_settings_only.ini ##################################### # MongoDB: diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index d99bf69f..98d107bd 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -49,6 +49,8 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ pecl install xdebug && \ docker-php-ext-enable xdebug \ ;fi +# ADD for REMOTE debugging +COPY ./xdebug_settings_only.ini /usr/local/etc/php/conf.d/xdebug_settings_only.ini ##################################### # MongoDB: diff --git a/php-fpm/xdebug_settings_only.ini b/php-fpm/xdebug_settings_only.ini new file mode 100644 index 00000000..51bfc622 --- /dev/null +++ b/php-fpm/xdebug_settings_only.ini @@ -0,0 +1,21 @@ +; NOTE: The actual debug.so extention is NOT SET HERE but rather +; /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +; For example: +; zend_extension=xdebug.so + +xdebug.remote_autostart=1 +xdebug.remote_enable=1 +xdebug.remote_handler=dbgp +xdebug.remote_mode=req + +; In PHPStorm: Settings > Languages & Frameworks > PHP > Debug > Xdebug > Debug port +xdebug.remote_port=9000 + +; This is passed with by docker-compose / workspace / extra_hosts / - "dockerhost:10.0.75.1" +; It will set 10.0.75.1 dockerhost +; This will allow xdebug to connect to the host running PHPStorm. +xdebug.remote_host=dockerhost + +; PHPStorm needs this +xdebug.idekey=PHPSTORM + diff --git a/workspace/Dockerfile b/workspace/Dockerfile index f414f34b..31d47ecf 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -52,6 +52,8 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ sed -i 's/^/;/g' /etc/php/7.0/cli/conf.d/20-xdebug.ini && \ echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/laravel/vendor/bin/phpunit'" >> ~/.bashrc \ ;fi +# ADD for REMOTE debugging +COPY ./xdebug_settings_only.ini /etc/php/7.0/cli/conf.d/xdebug_settings_only.ini ##################################### # MongoDB: diff --git a/workspace/xdebug_settings_only.ini b/workspace/xdebug_settings_only.ini new file mode 100644 index 00000000..9399614e --- /dev/null +++ b/workspace/xdebug_settings_only.ini @@ -0,0 +1,20 @@ +; NOTE: The actual debug.so extention is NOT SET HERE but rather +; /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +; For example: +; zend_extension=xdebug.so + +xdebug.remote_autostart=1 +xdebug.remote_enable=1 +xdebug.remote_handler=dbgp +xdebug.remote_mode=req + +; In PHPStorm: Settings > Languages & Frameworks > PHP > Debug > Xdebug > Debug port +xdebug.remote_port=9000 + +; This is passed with by docker-compose / workspace / extra_hosts / - "dockerhost:10.0.75.1" +; It will set 10.0.75.1 dockerhost +; This will allow xdebug to connect to the host running PHPStorm. +xdebug.remote_host=dockerhost + +; PHPStorm needs this +xdebug.idekey=PHPSTORM diff --git a/xdebugPhpFpm b/xdebugPhpFpm new file mode 100644 index 00000000..f1847448 --- /dev/null +++ b/xdebugPhpFpm @@ -0,0 +1,91 @@ +#! /bin/bash + +# NOTE: At the moment, this has only been confirmed to work PHP 7 + + +# Grab full name of php-fpm container +PHP_FPM_CONTAINER=$(docker-compose ps | grep php-fpm | cut -d" " -f 1) + +xdebug_status () +{ + echo 'xDebug status' + + # If running on Windows, need to prepend with winpty :( + if [[ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]]; then + winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' + + else + docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' + fi + +} + +xdebug_start () +{ + echo 'Start xDebug' + + # And uncomment line with xdebug extension, thus enabling it + ON_CMD="sed -i 's/^;zend_extension=/zend_extension=/g' \ + /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" + + + # If running on Windows, need to prepend with winpty :( + if [[ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]]; then + winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${ON_CMD}" + docker restart $PHP_FPM_CONTAINER + winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' + + else + docker exec -it $PHP_FPM_CONTAINER bash -c "${ON_CMD}" + docker restart $PHP_FPM_CONTAINER + docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' + fi + +} + +xdebug_stop () +{ + echo 'Stop xDebug' + + # Comment out xdebug extension line + OFF_CMD="sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" + + + # If running on Windows, need to prepend with winpty :( + if [[ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]]; then + # This is the equivalent of: + # winpty docker exec -it laradock_php-fpm_1 bash -c 'bla bla bla' + # Thanks to @michaelarnauts at https://github.com/docker/compose/issues/593 + winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}" + docker restart $PHP_FPM_CONTAINER + #docker-compose restart php-fpm + winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' + + else + docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}" + # docker-compose restart php-fpm + docker restart $PHP_FPM_CONTAINER + docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' + fi +} + + +case $@ in + stop|STOP) + xdebug_stop + ;; + start|START) + xdebug_start + ;; + status|STATUS) + xdebug_status + ;; + *) + echo "xDebug [Stop | Start | Status] in the ${PHP_FPM_CONTAINER} container." + echo "xDebug must have already been installed." + echo "Usage:" + echo " ./xdebugPhpFpm stop|start|status" + +esac + +exit 1 From 93504a714dd5d0678dfec05e86a50253f3f0d28d Mon Sep 17 00:00:00 2001 From: larryeitel Date: Mon, 15 Aug 2016 15:14:05 -0600 Subject: [PATCH 05/22] Proof of concept - LaraDock hosting multiple sites --- .gitignore | 3 ++- docker-compose.yml | 11 +++++++++++ nginx/Dockerfile | 2 +- nginx/nginx.conf | 1 + nginx/{ => sites}/laravel.conf | 2 ++ nginx/sites/site_a.conf | 28 ++++++++++++++++++++++++++++ nginx/sites/site_b.conf | 28 ++++++++++++++++++++++++++++ 7 files changed, 73 insertions(+), 2 deletions(-) rename nginx/{ => sites}/laravel.conf (95%) create mode 100644 nginx/sites/site_a.conf create mode 100644 nginx/sites/site_b.conf diff --git a/.gitignore b/.gitignore index 28b085f1..00571d72 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea /logs /data -.env \ No newline at end of file +.env diff --git a/docker-compose.yml b/docker-compose.yml index a2313182..1bb1c49c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -203,6 +203,17 @@ services: volumes: - ../:/var/www/laravel + # By default, site_a and site_b are mirroring the parent Laravel app. + # This is because the nginx container has these domains + # enabled to demonstrate how to support multiple sites + - ../:/var/www/site_a + - ../:/var/www/site_b + + # This demonstrates example of where you may mount sites + # - ../../site_a/:/var/www/site_a + # - ../../site_b/:/var/www/site_b + + ### Databases Data Container ################################ volumes_data: diff --git a/nginx/Dockerfile b/nginx/Dockerfile index f9bfc1ba..2aece34b 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -3,7 +3,7 @@ FROM nginx:alpine MAINTAINER Mahmoud Zalt ADD nginx.conf /etc/nginx/ -ADD laravel.conf /etc/nginx/conf.d/laravel.conf +COPY sites/*.conf /etc/nginx/sites-available/ ARG PHP_UPSTREAM=php-fpm diff --git a/nginx/nginx.conf b/nginx/nginx.conf index cc7fa68e..3daeb998 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -24,5 +24,6 @@ http { gzip on; gzip_disable "msie6"; include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-available/*; open_file_cache max=100; } diff --git a/nginx/laravel.conf b/nginx/sites/laravel.conf similarity index 95% rename from nginx/laravel.conf rename to nginx/sites/laravel.conf index 432c2a71..c1803830 100644 --- a/nginx/laravel.conf +++ b/nginx/sites/laravel.conf @@ -1,7 +1,9 @@ server { + listen 80 default_server; listen [::]:80 default_server ipv6only=on; + server_name laravel; root /var/www/laravel/public; index index.php index.html index.htm; diff --git a/nginx/sites/site_a.conf b/nginx/sites/site_a.conf new file mode 100644 index 00000000..04eec45b --- /dev/null +++ b/nginx/sites/site_a.conf @@ -0,0 +1,28 @@ +server { + + listen 80; + listen [::]:80; + + server_name site_a; + root /var/www/site_a/public; + index index.php index.html index.htm; + + location / { + try_files $uri $uri/ /index.php$is_args$args; + } + + location ~ \.php$ { + try_files $uri /index.php =404; + fastcgi_pass php-upstream; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + + location ~ /\.ht { + deny all; + } +} + + + diff --git a/nginx/sites/site_b.conf b/nginx/sites/site_b.conf new file mode 100644 index 00000000..e1539cd1 --- /dev/null +++ b/nginx/sites/site_b.conf @@ -0,0 +1,28 @@ +server { + + listen 80; + listen [::]:80; + + server_name site_b; + root /var/www/site_b/public; + index index.php index.html index.htm; + + location / { + try_files $uri $uri/ /index.php$is_args$args; + } + + location ~ \.php$ { + try_files $uri /index.php =404; + fastcgi_pass php-upstream; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + + location ~ /\.ht { + deny all; + } +} + + + From a6e04aa6592fae11e948622014914f76dcdef9cd Mon Sep 17 00:00:00 2001 From: Suteepat Damrongyingsupab Date: Tue, 16 Aug 2016 16:31:52 +0700 Subject: [PATCH 06/22] Added PHP Memcached extension installation for PHP 5.6 --- docker-compose.yml | 1 + php-fpm/Dockerfile-56 | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index a2313182..7e8cc8fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,6 +27,7 @@ services: - INSTALL_MONGO=false - INSTALL_XDEBUG=false - INSTALL_ZIP_ARCHIVE=false + - INSTALL_MEMCACHED=false dockerfile: Dockerfile-70 volumes_from: - volumes_source diff --git a/php-fpm/Dockerfile-56 b/php-fpm/Dockerfile-56 index 3ac78e6f..876f1789 100644 --- a/php-fpm/Dockerfile-56 +++ b/php-fpm/Dockerfile-56 @@ -36,6 +36,7 @@ MAINTAINER Mahmoud Zalt # - INSTALL_XDEBUG= false # - INSTALL_MONGO= false # - INSTALL_ZIP_ARCHIVE= false +# - INSTALL_MEMCACHED= false # ##################################### @@ -74,6 +75,18 @@ RUN if [ ${INSTALL_ZIP_ARCHIVE} = true ]; then \ docker-php-ext-enable zip \ ;fi +##################################### +# PHP Memcached: +##################################### + +ARG INSTALL_MEMCACHED=true +ENV INSTALL_MEMCACHED ${INSTALL_MEMCACHED} +RUN if [ ${INSTALL_MEMCACHED} = true ]; then \ + # Install the php memcached extension + pecl install memcached && \ + docker-php-ext-enable memcached \ +;fi + # #-------------------------------------------------------------------------- From d3a6116a42810eb69c666aa58e5f505ca108c0e5 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Tue, 16 Aug 2016 15:12:35 +0300 Subject: [PATCH 07/22] move PHP Memcached from the base image to LaraDock --- php-fpm/Dockerfile-70 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index d99bf69f..08427d36 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -36,6 +36,7 @@ MAINTAINER Mahmoud Zalt # - INSTALL_XDEBUG= false # - INSTALL_MONGO= false # - INSTALL_ZIP_ARCHIVE= false +# - INSTALL_MEMCACHED= false # ##################################### @@ -74,6 +75,29 @@ RUN if [ ${INSTALL_ZIP_ARCHIVE} = true ]; then \ docker-php-ext-enable zip \ ;fi +##################################### +# PHP Memcached: +##################################### + +ARG INSTALL_MEMCACHED=true +ENV INSTALL_MEMCACHED ${INSTALL_MEMCACHED} +RUN if [ ${INSTALL_MEMCACHED} = true ]; then \ + # Install the php memcached extension + curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached-dev/php-memcached/archive/php7.tar.gz" \ + && mkdir -p memcached \ + && tar -C memcached -zxvf /tmp/memcached.tar.gz --strip 1 \ + && ( \ + cd memcached \ + && phpize \ + && ./configure \ + && make -j$(nproc) \ + && make install \ + ) \ + && rm -r memcached \ + && rm /tmp/memcached.tar.gz \ + && docker-php-ext-enable memcached \ +;fi + # #-------------------------------------------------------------------------- From aabb0cded86e405eb055131d6e37102820317c98 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Tue, 16 Aug 2016 15:12:52 +0300 Subject: [PATCH 08/22] upgrade php-fpm base image --- php-fpm/Dockerfile-56 | 2 +- php-fpm/Dockerfile-70 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/php-fpm/Dockerfile-56 b/php-fpm/Dockerfile-56 index 876f1789..9c173744 100644 --- a/php-fpm/Dockerfile-56 +++ b/php-fpm/Dockerfile-56 @@ -10,7 +10,7 @@ # https://hub.docker.com/r/laradock/php-fpm/tags/ # -FROM laradock/php-fpm:5.6--1.1 +FROM laradock/php-fpm:5.6--1.2 MAINTAINER Mahmoud Zalt diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index 08427d36..7db010f4 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -10,7 +10,7 @@ # https://hub.docker.com/r/laradock/php-fpm/tags/ # -FROM laradock/php-fpm:7.0--1.1 +FROM laradock/php-fpm:7.0--1.2 MAINTAINER Mahmoud Zalt From 5232d6a84fbc250edefb8340d8d54b209ac9819f Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Tue, 16 Aug 2016 15:28:30 +0300 Subject: [PATCH 09/22] update the readme: add xDebug docs --- README.md | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 77e20266..2b5f529f 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant. - [Change the PHP-FPM Version](#Change-the-PHP-FPM-Version) - [Change the PHP-CLI Version](#Change-the-PHP-CLI-Version) - [Install xDebug](#Install-xDebug) + - [Start/Stop xDebug](#Controll-xDebug) - [Misc](#Misc) - [Use custom Domain](#Use-custom-Domain) - [Enable Global Composer Build Install](#Enable-Global-Composer-Build-Install) @@ -833,6 +834,24 @@ It should be like this: 2 - Re-build the containers `docker-compose build workspace php-fpm` +For information on how to configure xDebug with your IDE and work it out, check this [Repository](https://github.com/LarryEitel/laravel-laradock-phpstorm). + + +
+ +### Start/Stop xDebug: + +By installing xDebug, you are enabling it to run on startup by default. + +To controll the behavior of xDebug (in the `php-fpm` Container), you can run the following commands from the LaraDock root folder: + +- Stop xDebug from running by default: `./xdebugPhpFpm stop`. +- Start xDebug by default: `./xdebugPhpFpm start`. +- See the status: `./xdebugPhpFpm status`. + + + +
@@ -957,12 +976,10 @@ Use `http://127.0.0.1` instead of `http://localhost` in your browser. Make sure the ports for the services that you are trying to run (80, 3306, etc.) are not being used already by other programs, such as a built in `apache`/`httpd` service or other development tools you have installed. -#### Stopping and Starting xdebug -By default, if you have chosen to install xDebug, it will be running/enabled on startup. -- To stop xdebug in the `php-fpm` container, from your laradock folder, run: `./xdebugPhpFpm stop`. -- To start, run: `./xdebugPhpFpm start`. -- To see php -v, run: `./xdebugPhpFpm status`. + + +
@@ -1010,6 +1027,7 @@ For special help with Docker and/or Laravel, you can schedule a live call with t **Main Contributors:** +- [Larry Eitel (LarryEitel)](https://github.com/LarryEitel) - [Suteepat (tianissimo)](https://github.com/tianissimo) - [David (davidavz)](https://github.com/davidavz) - [Lialosiu](https://github.com/lialosiu) From 1614f0fb2db00504f378418e22ba587bf742c5d8 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Tue, 16 Aug 2016 15:38:01 +0300 Subject: [PATCH 10/22] update the readme: add production section (with DO) --- README.md | 231 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) diff --git a/README.md b/README.md index 2b5f529f..60f5af89 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ It's like Laravel Homestead but for Docker instead of Vagrant. - [Change the PHP-CLI Version](#Change-the-PHP-CLI-Version) - [Install xDebug](#Install-xDebug) - [Start/Stop xDebug](#Controll-xDebug) + - [Production](#Production) + - [Setup Laravel and Docker on Digital Ocean](#Digital-Ocean) - [Misc](#Misc) - [Use custom Domain](#Use-custom-Domain) - [Enable Global Composer Build Install](#Enable-Global-Composer-Build-Install) @@ -853,6 +855,235 @@ To controll the behavior of xDebug (in the `php-fpm` Container), you can run the +
+ +### [Production] + + +
+ +### Setup Laravel and Docker on Digital Ocean + + +#### Install Docker +``` +Login Digital Ocean +Add Droplet +1 Click Install docker +Choose Droplet +reset ROOT password +check email +``` + +#### SSH to your Server + +``` +ssh root@ipaddress +``` +you will be prompt of that password. +type the password you receive in your email + +then it will ask to you to change a new password +just change it to the custom root password you want + +After SSH +you can check that docker command is working by typing + +``` +$root@midascode:~# docker +``` + +#### Set Up Your Laravel Project + +``` +$root@midascode:~# apt-get install git +$root@midascode:~# git clone https://github.com/laravel/laravel +$root@midascode:~# cd laravel +$root@midascode:~/laravel# git checkout develop +$root@midascode:~/laravel/ git submodule add https://github.com/LaraDock/laradock.git +$root@midascode:~/laravel/ cd laradock +``` + +#### Install docker-compose command + +``` +$root@midascode:~/laravel/laradock# curl -L https://github.com/docker/compose/releases/download/1.8.0/run.sh > /usr/local/bin/docker-compose +$root@midascode:~/chmod +x /usr/local/bin/docker-compose +``` + +#### Create Your LaraDock Containers + +``` +$root@midascode:~/laravel/laradock# docker-compose up -d nginx mysql +``` + +#### Go to Your Workspace + +``` +docker-compose exec workspace bash +``` + +#### Install laravel Dependencies, Add .env , generate Key and give proper permission certain folder + +``` +$ root@0e77851d27d3:/var/www/laravel# composer install +$ root@0e77851d27d3:/var/www/laravel# cp .env.example .env +$ root@0e77851d27d3:/var/www/laravel# php artisan key:generate +$ root@0e77851d27d3:/var/www/laravel# exit +$root@midascode:~/laravel/laradock# cd .. +$root@midascode:~/laravel# sudo chmod -R 777 storage bootstrap/cache +``` + +you can then view your laravel site at your ipaddress +for example +``` +192.168.1.1 +``` + +You will see there Laravel Default Welcome Page + +but if you need to view on your custom domain name +which you would. + +#### Using Your Own Domain Name +login to your DNS provider +Godaddy, Namecheap what ever... +And Point the Custom Domain Name Server to + +``` +ns1.digitalocean.com +ns2.digitalocean.com +ns3.digitalocean.com +``` +In Your Digital Ocean Account go to +``` +https://cloud.digitalocean.com/networking/domains +``` +add your domain name and choose the server ip you provision earlier + +#### Serve Site With NGINX (HTTP ONLY) +Go back to command line +``` +$root@midascode:~/laravel/laradock# cd nginx +$root@midascode:~/laravel/laradock/nginx# vim laravel.conf +``` +remove default_server +``` + + listen 80 default_server; + listen [::]:80 default_server ipv6only=on; + +``` + and add server_name (your custom domain) +``` + listen 80; + listen [::]:80 ipv6only=on; + server_name yourdomain.com; +``` + +#### Rebuild Your Nginx +``` +$root@midascode:~/laravel/laradock/nginx# docker-compose down +$root@midascode:~/laravel/laradock/nginx# docker-compose build nginx +``` + +#### Re Run Your Containers MYSQL and NGINX +``` +$root@midascode:~/laravel/laradock/nginx# docker-compose up -d nginx mysql +``` + +###### View Your Site with HTTP ONLY (http://yourdomain.com) + +#### Run Site on SSL with Let's Encrypt Certificate + +###### Note: You need to Use Caddy here Instead of Nginx + +###### To go Caddy Folders and Edit CaddyFile + +``` +$root@midascode:~/laravel/laradock# cd caddy +$root@midascode:~/laravel/laradock/caddy# vim Caddyfile +``` + +Remove 0.0.0.0:80 + +``` +0.0.0.0:80 +root /var/www/laravel/public +``` +and replace with your https://yourdomain.com + +``` +https://yourdomain.com +root /var/www/laravel/public +``` +uncomment tls + +``` +#tls self-signed +``` +and replace self-signed with your email address + +``` +tls midascodebreaker@gmai.com +``` +This is needed Prior to Creating Let's Encypt + +#### Run Your Caddy Container without the -d flag and Generate SSL with Let's Encrypt + +``` +$root@midascode:~/laravel/laradock/caddy# docker-compose up caddy +``` + +you will be prompt here to enter your email... you may enter it or not +``` +Attaching to laradock_mysql_1, laradock_caddy_1 +caddy_1 | Activating privacy features... +caddy_1 | Your sites will be served over HTTPS automatically using Let's Encrypt. +caddy_1 | By continuing, you agree to the Let's Encrypt Subscriber Agreement at: +caddy_1 | https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf +caddy_1 | Activating privacy features... done. +caddy_1 | https://yourdomain.com +caddy_1 | http://yourdomain.com +``` + +After it finish Press Ctrl + C to exit ... + +#### Stop All Containers and ReRun Caddy and Other Containers on Background + +``` +$root@midascode:~/laravel/laradock/caddy# docker-compose down +$root@midascode:~/laravel/laradock/caddy# docker-compose up -d mysql caddy +``` +View your Site in the Browser Securely Using HTTPS (https://yourdomain.com) + +##### Note that Certificate will be Automatically Renew By Caddy + +>References: +> +- [https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04) +- [https://www.digitalocean.com/products/one-click-apps/docker/](https://www.digitalocean.com/products/one-click-apps/docker/) +- [https://docs.docker.com/engine/installation/linux/ubuntulinux/](https://docs.docker.com/engine/installation/linux/ubuntulinux/) +- [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/) +- [https://caddyserver.com/docs/automatic-https](https://caddyserver.com/docs/automatic-https) +- [https://caddyserver.com/docs/tls](https://caddyserver.com/docs/tls) +- [https://caddyserver.com/docs/caddyfile](https://caddyserver.com/docs/caddyfile) + + + + + + + + + + + + + + + +
### [Misc] From e8562272b03b477a436a9023f381a969886c7dbb Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Tue, 16 Aug 2016 15:47:42 +0300 Subject: [PATCH 11/22] update the readme: update contributing giude --- CONTRIBUTING.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9e1cedbc..3fd3b67b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,9 +54,21 @@ Help us to maximize the effort we can spend fixing issues and adding new features, by not reporting duplicate issues. +### Before Submitting a Pull Request (PR) -### Submitting a Pull Request (PR) -Before you submit your pull request consider the following guidelines: +Always Test everything and make sure its working: + +- Pull the latest updates (or fork of you don’t have permission) +- Before editing anything: + - Test building the container (docker-compose build --no-cache container-name) build with no cache first. + - Test running the container with some other containers in real app and see of everything is working fine. +- Now edit the container (edit section by section and test rebuilding the container after every edited section) + - Testing building the container (docker-compose build container-name) with no errors. + - Test it in real App. + + +### Submitting a PR +Consider the following guidelines: * Search [GitHub](https://github.com/LaraDock/laradock/pulls) for an open or closed Pull Request that relates to your submission. You don't want to duplicate effort. @@ -93,7 +105,7 @@ git push origin my-fix-branch -f -### After your pull request is merged +### After your PR is merged After your pull request is merged, you can safely delete your branch and pull the changes from the main (upstream) repository: From 1c22c009e74e7b87f3292dd52b446d3895b755c2 Mon Sep 17 00:00:00 2001 From: larryeitel Date: Tue, 16 Aug 2016 08:55:29 -0600 Subject: [PATCH 12/22] Indent - Start/Stop xDebug in TOC --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60f5af89..34615f35 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant. - [Install Prestissimo](#Install-Prestissimo) - [Install Node + NVM](#Install-Node) - [Debugging](#debugging) - - [Upgrading LaraDock](#upgrading-laradock) + - [Upgrading LaraDock](#upgrading-laradock) - [Help & Questions](#Help) From 7680e29bc51a7193358f56140ff68e213c26eac6 Mon Sep 17 00:00:00 2001 From: larryeitel Date: Tue, 16 Aug 2016 09:23:56 -0600 Subject: [PATCH 13/22] ReTweak README re xdebug --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 34615f35..0b9a60d7 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant. - [Change the PHP-FPM Version](#Change-the-PHP-FPM-Version) - [Change the PHP-CLI Version](#Change-the-PHP-CLI-Version) - [Install xDebug](#Install-xDebug) - - [Start/Stop xDebug](#Controll-xDebug) + - [Start/Stop xDebug](#Controll-xDebug) - [Production](#Production) - [Setup Laravel and Docker on Digital Ocean](#Digital-Ocean) - [Misc](#Misc) @@ -58,7 +58,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant. - [Install Prestissimo](#Install-Prestissimo) - [Install Node + NVM](#Install-Node) - [Debugging](#debugging) - - [Upgrading LaraDock](#upgrading-laradock) + - [Upgrading LaraDock](#upgrading-laradock) - [Help & Questions](#Help) From c324114b7a0f1d31ef089371f2e26692a922443c Mon Sep 17 00:00:00 2001 From: Tim Bracken Date: Tue, 16 Aug 2016 15:08:27 -0400 Subject: [PATCH 14/22] Add drupal 8 example to make laradock framework agnostic. --- nginx/sites/framework-examples/drupal_8.conf | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 nginx/sites/framework-examples/drupal_8.conf diff --git a/nginx/sites/framework-examples/drupal_8.conf b/nginx/sites/framework-examples/drupal_8.conf new file mode 100644 index 00000000..30ec9588 --- /dev/null +++ b/nginx/sites/framework-examples/drupal_8.conf @@ -0,0 +1,31 @@ +server { + listen 80; + listen [::]:80; + + server_name site_a.dev; + root /var/www/site_a; + index index.php; + + + location / { + try_files $uri $uri/ /index.php?q=$uri&$args; + } + + error_page 404 /404.html; + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /var/www/site_a; + } + + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + if (!-f $document_root$fastcgi_script_name) { + return 404; + } + + fastcgi_pass php-upstream; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} \ No newline at end of file From 95ef5e1e70b419f3cd8ba9f509dac28172c852eb Mon Sep 17 00:00:00 2001 From: Tim Bracken Date: Tue, 16 Aug 2016 15:13:58 -0400 Subject: [PATCH 15/22] Add Drush and Opcache to laradock because they are needed for drupal development. --- php-fpm/Dockerfile-56 | 6 ++++++ php-fpm/Dockerfile-70 | 6 ++++++ workspace/Dockerfile | 14 ++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/php-fpm/Dockerfile-56 b/php-fpm/Dockerfile-56 index 75daf66e..f1b8bd7c 100644 --- a/php-fpm/Dockerfile-56 +++ b/php-fpm/Dockerfile-56 @@ -89,6 +89,12 @@ RUN if [ ${INSTALL_MEMCACHED} = true ]; then \ docker-php-ext-enable memcached \ ;fi +##################################### +# Opcache: +##################################### +RUN docker-php-ext-install opcache +RUN docker-php-ext-enable opcache + # #-------------------------------------------------------------------------- diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index ca129bba..a4766bdc 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -100,6 +100,12 @@ RUN if [ ${INSTALL_MEMCACHED} = true ]; then \ && docker-php-ext-enable memcached \ ;fi +##################################### +# Opcache: +##################################### +RUN docker-php-ext-install opcache +RUN docker-php-ext-enable opcache + # #-------------------------------------------------------------------------- diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 31d47ecf..7caf004c 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -97,6 +97,20 @@ RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \ composer global install \ ;fi +##################################### +# Drush: +##################################### +ENV DRUSH_VERSION 8.1.2 + +# Install Drush 8 with the phar file. +USER root +RUN curl -fsSL -o /usr/local/bin/drush "https://github.com/drush-ops/drush/releases/download/$DRUSH_VERSION/drush.phar" && \ + chmod +x /usr/local/bin/drush + +#Check if drush works for the laradock user +USER laradock +RUN drush core-status + ##################################### # Node / NVM: ##################################### From 928451ae888212c0c94b4360d8834b8770b9799b Mon Sep 17 00:00:00 2001 From: Tim Bracken Date: Tue, 16 Aug 2016 16:32:59 -0400 Subject: [PATCH 16/22] This is a better Drupal nginx config. Built from a combination of contributions from here: https://groups.drupal.org/node/305633 https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/ --- nginx/sites/framework-examples/drupal_8.conf | 56 +++++++++++++++----- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/nginx/sites/framework-examples/drupal_8.conf b/nginx/sites/framework-examples/drupal_8.conf index 30ec9588..a5d398a1 100644 --- a/nginx/sites/framework-examples/drupal_8.conf +++ b/nginx/sites/framework-examples/drupal_8.conf @@ -1,28 +1,56 @@ server { - listen 80; + listen 80; listen [::]:80; - server_name site_a.dev; - root /var/www/site_a; - index index.php; + #domain name + server_name drupal8.dev; + #file document root. This has to match one of the volumes in docer-composer.yml + root /var/www/drupal8; + + # This is the full path to your index file + index index.php index.html index.htm; + + + ## serve imagecache files directly or redirect to drupal if they do not exist. + location ~* files/styles { + access_log off; + expires 30d; + try_files $uri @drupal; + } + + ## serve imagecache files directly or redirect to drupal if they do not exist. + location ~* ^.+.(xsl|xml)$ { + access_log off; + expires 1d; + try_files $uri @drupal; + } + + ## Images and static content is treated different + location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ { + access_log off; + expires 30d; + } location / { - try_files $uri $uri/ /index.php?q=$uri&$args; + index index.php; + # This is cool because no php is touched for static content + try_files $uri $uri/ @rewrite; + expires max; } - error_page 404 /404.html; - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /var/www/site_a; + location @drupal { + rewrite ^/(.*)$ /index.php?q=$1 last; } - location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - if (!-f $document_root$fastcgi_script_name) { - return 404; - } + location @rewrite { + # Some modules enforce no slash (/) at the end of the URL + # Else this rewrite block wouldn't be needed (GlobalRedirect) + rewrite ^/(.*)$ /index.php?q=$1; + } + + location ~ .php$ { fastcgi_pass php-upstream; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; From cfc81fca643b028363684481880c6f98486059eb Mon Sep 17 00:00:00 2001 From: Tim Bracken Date: Tue, 16 Aug 2016 17:51:41 -0400 Subject: [PATCH 17/22] Allow for config of crush and opcache in the main docker file --- docker-compose.yml | 2 ++ php-fpm/Dockerfile-56 | 8 ++++++-- php-fpm/Dockerfile-70 | 9 +++++++-- workspace/Dockerfile | 17 ++++++++++------- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 50135073..355d4581 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,7 @@ services: - INSTALL_MONGO=false - INSTALL_XDEBUG=false - INSTALL_NODE=false + - INSTALL_DRUSH=false - COMPOSER_GLOBAL_INSTALL=false - PUID=1000 - PGID=1000 @@ -33,6 +34,7 @@ services: - INSTALL_XDEBUG=false - INSTALL_ZIP_ARCHIVE=false - INSTALL_MEMCACHED=false + - INSTALL_OPCACHE=false dockerfile: Dockerfile-70 volumes_from: - volumes_source diff --git a/php-fpm/Dockerfile-56 b/php-fpm/Dockerfile-56 index f1b8bd7c..62ac6f9f 100644 --- a/php-fpm/Dockerfile-56 +++ b/php-fpm/Dockerfile-56 @@ -92,8 +92,12 @@ RUN if [ ${INSTALL_MEMCACHED} = true ]; then \ ##################################### # Opcache: ##################################### -RUN docker-php-ext-install opcache -RUN docker-php-ext-enable opcache +ARG INSTALL_OPCACHE=true +ENV INSTALL_OPCACHE ${INSTALL_OPCACHE} +RUN if [ ${INSTALL_OPCACHE} = true ]; then \ + docker-php-ext-install opcache && \ + docker-php-ext-enable opcache \ +;fi # diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index a4766bdc..8c296ce3 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -103,8 +103,13 @@ RUN if [ ${INSTALL_MEMCACHED} = true ]; then \ ##################################### # Opcache: ##################################### -RUN docker-php-ext-install opcache -RUN docker-php-ext-enable opcache +ARG INSTALL_OPCACHE=true +ENV INSTALL_OPCACHE ${INSTALL_OPCACHE} +RUN if [ ${INSTALL_OPCACHE} = true ]; then \ + docker-php-ext-install opcache && \ + docker-php-ext-enable opcache \ +;fi + # diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 7caf004c..1f728bd0 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -37,6 +37,7 @@ MAINTAINER Mahmoud Zalt # - INSTALL_MONGO= false # - COMPOSER_GLOBAL_INSTALL= false # - INSTALL_NODE= false +# - INSTALL_drush= false # ##################################### @@ -100,16 +101,18 @@ RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \ ##################################### # Drush: ##################################### -ENV DRUSH_VERSION 8.1.2 - -# Install Drush 8 with the phar file. USER root -RUN curl -fsSL -o /usr/local/bin/drush "https://github.com/drush-ops/drush/releases/download/$DRUSH_VERSION/drush.phar" && \ - chmod +x /usr/local/bin/drush +ENV DRUSH_VERSION 8.1.2 +ARG INSTALL_DRUSH=true +ENV INSTALL_DRUSH ${INSTALL_DRUSH} +RUN if [ ${INSTALL_DRUSH} = true ]; then \ + # Install Drush 8 with the phar file. + curl -fsSL -o /usr/local/bin/drush https://github.com/drush-ops/drush/releases/download/$DRUSH_VERSION/drush.phar | bash && \ + chmod +x /usr/local/bin/drush && \ + drush core-status \ +;fi -#Check if drush works for the laradock user USER laradock -RUN drush core-status ##################################### # Node / NVM: From b648f1ca58ee2cf292260a466e1d4199d03395af Mon Sep 17 00:00:00 2001 From: Tim Bracken Date: Tue, 16 Aug 2016 17:53:15 -0400 Subject: [PATCH 18/22] Fix typo --- workspace/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 1f728bd0..e5338f64 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -37,7 +37,7 @@ MAINTAINER Mahmoud Zalt # - INSTALL_MONGO= false # - COMPOSER_GLOBAL_INSTALL= false # - INSTALL_NODE= false -# - INSTALL_drush= false +# - INSTALL_DRUSH= false # ##################################### From d57a0c3888cc3cb0d2f1543f84d94bc5ada72822 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Fri, 19 Aug 2016 03:03:45 +0300 Subject: [PATCH 19/22] rename and refactor xdebug config files --- php-fpm/xdebug.ini | 12 ++++++++++++ php-fpm/xdebug_settings_only.ini | 21 --------------------- workspace/xdebug.ini | 12 ++++++++++++ workspace/xdebug_settings_only.ini | 20 -------------------- 4 files changed, 24 insertions(+), 41 deletions(-) create mode 100644 php-fpm/xdebug.ini delete mode 100644 php-fpm/xdebug_settings_only.ini create mode 100644 workspace/xdebug.ini delete mode 100644 workspace/xdebug_settings_only.ini diff --git a/php-fpm/xdebug.ini b/php-fpm/xdebug.ini new file mode 100644 index 00000000..06eef4a9 --- /dev/null +++ b/php-fpm/xdebug.ini @@ -0,0 +1,12 @@ +; NOTE: The actual debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini) + +xdebug.remote_autostart=1 +xdebug.remote_enable=1 +xdebug.remote_connect_back=1 +xdebug.cli_color=1 +xdebug.remote_handler=dbgp +xdebug.remote_mode=req + +xdebug.remote_port=9000 +xdebug.remote_host=dockerhost +xdebug.idekey=PHPSTORM diff --git a/php-fpm/xdebug_settings_only.ini b/php-fpm/xdebug_settings_only.ini deleted file mode 100644 index 51bfc622..00000000 --- a/php-fpm/xdebug_settings_only.ini +++ /dev/null @@ -1,21 +0,0 @@ -; NOTE: The actual debug.so extention is NOT SET HERE but rather -; /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -; For example: -; zend_extension=xdebug.so - -xdebug.remote_autostart=1 -xdebug.remote_enable=1 -xdebug.remote_handler=dbgp -xdebug.remote_mode=req - -; In PHPStorm: Settings > Languages & Frameworks > PHP > Debug > Xdebug > Debug port -xdebug.remote_port=9000 - -; This is passed with by docker-compose / workspace / extra_hosts / - "dockerhost:10.0.75.1" -; It will set 10.0.75.1 dockerhost -; This will allow xdebug to connect to the host running PHPStorm. -xdebug.remote_host=dockerhost - -; PHPStorm needs this -xdebug.idekey=PHPSTORM - diff --git a/workspace/xdebug.ini b/workspace/xdebug.ini new file mode 100644 index 00000000..06eef4a9 --- /dev/null +++ b/workspace/xdebug.ini @@ -0,0 +1,12 @@ +; NOTE: The actual debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini) + +xdebug.remote_autostart=1 +xdebug.remote_enable=1 +xdebug.remote_connect_back=1 +xdebug.cli_color=1 +xdebug.remote_handler=dbgp +xdebug.remote_mode=req + +xdebug.remote_port=9000 +xdebug.remote_host=dockerhost +xdebug.idekey=PHPSTORM diff --git a/workspace/xdebug_settings_only.ini b/workspace/xdebug_settings_only.ini deleted file mode 100644 index 9399614e..00000000 --- a/workspace/xdebug_settings_only.ini +++ /dev/null @@ -1,20 +0,0 @@ -; NOTE: The actual debug.so extention is NOT SET HERE but rather -; /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -; For example: -; zend_extension=xdebug.so - -xdebug.remote_autostart=1 -xdebug.remote_enable=1 -xdebug.remote_handler=dbgp -xdebug.remote_mode=req - -; In PHPStorm: Settings > Languages & Frameworks > PHP > Debug > Xdebug > Debug port -xdebug.remote_port=9000 - -; This is passed with by docker-compose / workspace / extra_hosts / - "dockerhost:10.0.75.1" -; It will set 10.0.75.1 dockerhost -; This will allow xdebug to connect to the host running PHPStorm. -xdebug.remote_host=dockerhost - -; PHPStorm needs this -xdebug.idekey=PHPSTORM From dd48592d8b2431621e27a9159160c593434359d9 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Fri, 19 Aug 2016 03:05:02 +0300 Subject: [PATCH 20/22] update the xdebug.ini usage --- php-fpm/Dockerfile-56 | 13 +++++-------- php-fpm/Dockerfile-70 | 12 +++++------- workspace/Dockerfile | 2 +- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/php-fpm/Dockerfile-56 b/php-fpm/Dockerfile-56 index 62ac6f9f..60a67a28 100644 --- a/php-fpm/Dockerfile-56 +++ b/php-fpm/Dockerfile-56 @@ -32,11 +32,8 @@ MAINTAINER Mahmoud Zalt # # Optional Software's will only be installed if you set them to `true` # in the `docker-compose.yml` before the build. -# -# - INSTALL_XDEBUG= false -# - INSTALL_MONGO= false -# - INSTALL_ZIP_ARCHIVE= false -# - INSTALL_MEMCACHED= false +# Example: +# - INSTALL_ZIP_ARCHIVE=true # ##################################### @@ -50,8 +47,9 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ pecl install xdebug && \ docker-php-ext-enable xdebug \ ;fi -# ADD for REMOTE debugging -COPY ./xdebug_settings_only.ini /usr/local/etc/php/conf.d/xdebug_settings_only.ini + +# Copy xdebug configration for remote debugging +COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini ##################################### # MongoDB: @@ -99,7 +97,6 @@ RUN if [ ${INSTALL_OPCACHE} = true ]; then \ docker-php-ext-enable opcache \ ;fi - # #-------------------------------------------------------------------------- # Final Touch diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index 8c296ce3..fe412775 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -32,11 +32,8 @@ MAINTAINER Mahmoud Zalt # # Optional Software's will only be installed if you set them to `true` # in the `docker-compose.yml` before the build. -# -# - INSTALL_XDEBUG= false -# - INSTALL_MONGO= false -# - INSTALL_ZIP_ARCHIVE= false -# - INSTALL_MEMCACHED= false +# Example: +# - INSTALL_ZIP_ARCHIVE=true # ##################################### @@ -50,8 +47,9 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ pecl install xdebug && \ docker-php-ext-enable xdebug \ ;fi -# ADD for REMOTE debugging -COPY ./xdebug_settings_only.ini /usr/local/etc/php/conf.d/xdebug_settings_only.ini + +# Copy xdebug configration for remote debugging +COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini ##################################### # MongoDB: diff --git a/workspace/Dockerfile b/workspace/Dockerfile index e5338f64..e869bfab 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -54,7 +54,7 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/laravel/vendor/bin/phpunit'" >> ~/.bashrc \ ;fi # ADD for REMOTE debugging -COPY ./xdebug_settings_only.ini /etc/php/7.0/cli/conf.d/xdebug_settings_only.ini +COPY ./xdebug.ini /etc/php/7.0/cli/conf.d/xdebug.ini ##################################### # MongoDB: From e75da747a9ce41568443b8a2ea820b54bc47e3d9 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Fri, 19 Aug 2016 03:05:36 +0300 Subject: [PATCH 21/22] general clean up --- docker-compose.yml | 27 +++++--------------- nginx/sites/framework-examples/drupal_8.conf | 6 ++--- nginx/sites/laravel.conf | 2 +- nginx/sites/site_a.conf | 2 +- xdebugPhpFpm | 2 +- 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 355d4581..1c89a00a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,8 +8,8 @@ services: build: context: ./workspace args: - - INSTALL_MONGO=false - INSTALL_XDEBUG=false + - INSTALL_MONGO=false - INSTALL_NODE=false - INSTALL_DRUSH=false - COMPOSER_GLOBAL_INSTALL=false @@ -18,9 +18,7 @@ services: volumes_from: - volumes_source extra_hosts: - # IMPORTANT: Replace with your Docker Host IP - # this will be appended to /etc/hosts - # Note that this IP can perhaps be better injected via .env + # IMPORTANT: Replace with your Docker Host IP (will be appended to /etc/hosts) - "dockerhost:10.0.75.1" tty: true @@ -30,8 +28,8 @@ services: build: context: ./php-fpm args: - - INSTALL_MONGO=false - INSTALL_XDEBUG=false + - INSTALL_MONGO=false - INSTALL_ZIP_ARCHIVE=false - INSTALL_MEMCACHED=false - INSTALL_OPCACHE=false @@ -43,15 +41,10 @@ services: links: - workspace extra_hosts: - # IMPORTANT: Replace with your Docker Host IP - # this will be appended to /etc/hosts - # Note that this IP can perhaps be better injected via .env + # IMPORTANT: Replace with your Docker Host IP (will be appended to /etc/hosts) - "dockerhost:10.0.75.1" environment: - # IMPORTANT: You must have a Remote Interpreter entry matching this name - # In settings, search for interpreter... - # PHP > Languages & Frameworks > PHP > Interpreter > click on [...] - # Need to have a Remote Interpreter named 'laravel' + # IMPORTANT: Set the Remote Interpreter entry matching name to `laravel` - PHP_IDE_CONFIG="serverName=laravel" ### Nginx Server Container ################################## @@ -221,18 +214,10 @@ services: build: ./volumes/application volumes: - ../:/var/www/laravel - - # By default, site_a and site_b are mirroring the parent Laravel app. - # This is because the nginx container has these domains - # enabled to demonstrate how to support multiple sites - - ../:/var/www/site_a - - ../:/var/www/site_b - - # This demonstrates example of where you may mount sites + # Demonstration of how to mount multiple sites # - ../../site_a/:/var/www/site_a # - ../../site_b/:/var/www/site_b - ### Databases Data Container ################################ volumes_data: diff --git a/nginx/sites/framework-examples/drupal_8.conf b/nginx/sites/framework-examples/drupal_8.conf index a5d398a1..fea06905 100644 --- a/nginx/sites/framework-examples/drupal_8.conf +++ b/nginx/sites/framework-examples/drupal_8.conf @@ -1,5 +1,5 @@ server { - listen 80; + listen 80; listen [::]:80; #domain name @@ -11,7 +11,6 @@ server { # This is the full path to your index file index index.php index.html index.htm; - ## serve imagecache files directly or redirect to drupal if they do not exist. location ~* files/styles { access_log off; @@ -43,7 +42,6 @@ server { rewrite ^/(.*)$ /index.php?q=$1 last; } - location @rewrite { # Some modules enforce no slash (/) at the end of the URL # Else this rewrite block wouldn't be needed (GlobalRedirect) @@ -56,4 +54,4 @@ server { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } -} \ No newline at end of file +} diff --git a/nginx/sites/laravel.conf b/nginx/sites/laravel.conf index c1803830..a40a7f14 100644 --- a/nginx/sites/laravel.conf +++ b/nginx/sites/laravel.conf @@ -3,7 +3,7 @@ server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; - server_name laravel; + server_name laravel; root /var/www/laravel/public; index index.php index.html index.htm; diff --git a/nginx/sites/site_a.conf b/nginx/sites/site_a.conf index 04eec45b..6bd32690 100644 --- a/nginx/sites/site_a.conf +++ b/nginx/sites/site_a.conf @@ -3,7 +3,7 @@ server { listen 80; listen [::]:80; - server_name site_a; + server_name site_a; root /var/www/site_a/public; index index.php index.html index.htm; diff --git a/xdebugPhpFpm b/xdebugPhpFpm index f1847448..1a343ce5 100644 --- a/xdebugPhpFpm +++ b/xdebugPhpFpm @@ -1,6 +1,6 @@ #! /bin/bash -# NOTE: At the moment, this has only been confirmed to work PHP 7 +# NOTE: At the moment, this has only been confirmed to work with PHP 7 # Grab full name of php-fpm container From fb049ef3008ae516ca8c20599e7e043e36345006 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Fri, 19 Aug 2016 03:24:02 +0300 Subject: [PATCH 22/22] create guides folder and clean the readme --- README.md | 225 +-------------------- CONTRIBUTING.md => _guides/contributing.md | 4 +- _guides/digital_ocean.md | 214 ++++++++++++++++++++ 3 files changed, 224 insertions(+), 219 deletions(-) rename CONTRIBUTING.md => _guides/contributing.md (99%) create mode 100644 _guides/digital_ocean.md diff --git a/README.md b/README.md index 0b9a60d7..b466c9fe 100644 --- a/README.md +++ b/README.md @@ -293,7 +293,7 @@ If you need a special support. Contact me, more details in the [Help & Questions -### [Docker] + @@ -475,7 +475,6 @@ docker logs {container-name}
-### [Laravel] @@ -704,7 +703,6 @@ More details about this [here](https://github.com/jenssegers/laravel-mongodb#ins
-### [PHP] @@ -857,223 +855,15 @@ To controll the behavior of xDebug (in the `php-fpm` Container), you can run the
-### [Production] + +
### Setup Laravel and Docker on Digital Ocean - -#### Install Docker -``` -Login Digital Ocean -Add Droplet -1 Click Install docker -Choose Droplet -reset ROOT password -check email -``` - -#### SSH to your Server - -``` -ssh root@ipaddress -``` -you will be prompt of that password. -type the password you receive in your email - -then it will ask to you to change a new password -just change it to the custom root password you want - -After SSH -you can check that docker command is working by typing - -``` -$root@midascode:~# docker -``` - -#### Set Up Your Laravel Project - -``` -$root@midascode:~# apt-get install git -$root@midascode:~# git clone https://github.com/laravel/laravel -$root@midascode:~# cd laravel -$root@midascode:~/laravel# git checkout develop -$root@midascode:~/laravel/ git submodule add https://github.com/LaraDock/laradock.git -$root@midascode:~/laravel/ cd laradock -``` - -#### Install docker-compose command - -``` -$root@midascode:~/laravel/laradock# curl -L https://github.com/docker/compose/releases/download/1.8.0/run.sh > /usr/local/bin/docker-compose -$root@midascode:~/chmod +x /usr/local/bin/docker-compose -``` - -#### Create Your LaraDock Containers - -``` -$root@midascode:~/laravel/laradock# docker-compose up -d nginx mysql -``` - -#### Go to Your Workspace - -``` -docker-compose exec workspace bash -``` - -#### Install laravel Dependencies, Add .env , generate Key and give proper permission certain folder - -``` -$ root@0e77851d27d3:/var/www/laravel# composer install -$ root@0e77851d27d3:/var/www/laravel# cp .env.example .env -$ root@0e77851d27d3:/var/www/laravel# php artisan key:generate -$ root@0e77851d27d3:/var/www/laravel# exit -$root@midascode:~/laravel/laradock# cd .. -$root@midascode:~/laravel# sudo chmod -R 777 storage bootstrap/cache -``` - -you can then view your laravel site at your ipaddress -for example -``` -192.168.1.1 -``` - -You will see there Laravel Default Welcome Page - -but if you need to view on your custom domain name -which you would. - -#### Using Your Own Domain Name -login to your DNS provider -Godaddy, Namecheap what ever... -And Point the Custom Domain Name Server to - -``` -ns1.digitalocean.com -ns2.digitalocean.com -ns3.digitalocean.com -``` -In Your Digital Ocean Account go to -``` -https://cloud.digitalocean.com/networking/domains -``` -add your domain name and choose the server ip you provision earlier - -#### Serve Site With NGINX (HTTP ONLY) -Go back to command line -``` -$root@midascode:~/laravel/laradock# cd nginx -$root@midascode:~/laravel/laradock/nginx# vim laravel.conf -``` -remove default_server -``` - - listen 80 default_server; - listen [::]:80 default_server ipv6only=on; - -``` - and add server_name (your custom domain) -``` - listen 80; - listen [::]:80 ipv6only=on; - server_name yourdomain.com; -``` - -#### Rebuild Your Nginx -``` -$root@midascode:~/laravel/laradock/nginx# docker-compose down -$root@midascode:~/laravel/laradock/nginx# docker-compose build nginx -``` - -#### Re Run Your Containers MYSQL and NGINX -``` -$root@midascode:~/laravel/laradock/nginx# docker-compose up -d nginx mysql -``` - -###### View Your Site with HTTP ONLY (http://yourdomain.com) - -#### Run Site on SSL with Let's Encrypt Certificate - -###### Note: You need to Use Caddy here Instead of Nginx - -###### To go Caddy Folders and Edit CaddyFile - -``` -$root@midascode:~/laravel/laradock# cd caddy -$root@midascode:~/laravel/laradock/caddy# vim Caddyfile -``` - -Remove 0.0.0.0:80 - -``` -0.0.0.0:80 -root /var/www/laravel/public -``` -and replace with your https://yourdomain.com - -``` -https://yourdomain.com -root /var/www/laravel/public -``` -uncomment tls - -``` -#tls self-signed -``` -and replace self-signed with your email address - -``` -tls midascodebreaker@gmai.com -``` -This is needed Prior to Creating Let's Encypt - -#### Run Your Caddy Container without the -d flag and Generate SSL with Let's Encrypt - -``` -$root@midascode:~/laravel/laradock/caddy# docker-compose up caddy -``` - -you will be prompt here to enter your email... you may enter it or not -``` -Attaching to laradock_mysql_1, laradock_caddy_1 -caddy_1 | Activating privacy features... -caddy_1 | Your sites will be served over HTTPS automatically using Let's Encrypt. -caddy_1 | By continuing, you agree to the Let's Encrypt Subscriber Agreement at: -caddy_1 | https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf -caddy_1 | Activating privacy features... done. -caddy_1 | https://yourdomain.com -caddy_1 | http://yourdomain.com -``` - -After it finish Press Ctrl + C to exit ... - -#### Stop All Containers and ReRun Caddy and Other Containers on Background - -``` -$root@midascode:~/laravel/laradock/caddy# docker-compose down -$root@midascode:~/laravel/laradock/caddy# docker-compose up -d mysql caddy -``` -View your Site in the Browser Securely Using HTTPS (https://yourdomain.com) - -##### Note that Certificate will be Automatically Renew By Caddy - ->References: -> -- [https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04) -- [https://www.digitalocean.com/products/one-click-apps/docker/](https://www.digitalocean.com/products/one-click-apps/docker/) -- [https://docs.docker.com/engine/installation/linux/ubuntulinux/](https://docs.docker.com/engine/installation/linux/ubuntulinux/) -- [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/) -- [https://caddyserver.com/docs/automatic-https](https://caddyserver.com/docs/automatic-https) -- [https://caddyserver.com/docs/tls](https://caddyserver.com/docs/tls) -- [https://caddyserver.com/docs/caddyfile](https://caddyserver.com/docs/caddyfile) - - - - - - +####[Full Giude Here](https://github.com/LaraDock/laradock/blob/master/_guides/digital_ocean.md) @@ -1086,7 +876,9 @@ View your Site in the Browser Securely Using HTTPS (https://yourdomain.com)
-### [Misc] + + +
@@ -1239,7 +1031,7 @@ Moving from Docker Toolbox (VirtualBox) to Docker Native (for Mac/Windows). Requ This little project was built by one man who has a full time job and many responsibilities, so if you like this project and you find that it needs a bug fix or support for new software or upgrade any container, or anything else.. Do not hesitate to contribute, you are more than welcome :) -#### Read our [Contribution Guidelines](https://github.com/LaraDock/laradock/blob/master/CONTRIBUTING.md) +#### Read our [Contribution Guidelines](https://github.com/LaraDock/laradock/blob/master/_guides/contributing.md) ## Help & Questions @@ -1258,6 +1050,7 @@ For special help with Docker and/or Laravel, you can schedule a live call with t **Main Contributors:** +- [MidasCodeBreaker](https://github.com/midascodebreaker) - [Larry Eitel (LarryEitel)](https://github.com/LarryEitel) - [Suteepat (tianissimo)](https://github.com/tianissimo) - [David (davidavz)](https://github.com/davidavz) diff --git a/CONTRIBUTING.md b/_guides/contributing.md similarity index 99% rename from CONTRIBUTING.md rename to _guides/contributing.md index 3fd3b67b..b6cb9d41 100644 --- a/CONTRIBUTING.md +++ b/_guides/contributing.md @@ -1,5 +1,3 @@ - - # Contributing to LaraDock Your contribution is more than welcome. Let's keep LaraDock amazing. @@ -139,4 +137,4 @@ from the main (upstream) repository:
-### Happy Coding :) \ No newline at end of file +### Happy Coding :) diff --git a/_guides/digital_ocean.md b/_guides/digital_ocean.md new file mode 100644 index 00000000..3f47e52a --- /dev/null +++ b/_guides/digital_ocean.md @@ -0,0 +1,214 @@ +#### Install Docker +``` +Login Digital Ocean +Add Droplet +1 Click Install docker +Choose Droplet +reset ROOT password +check email +``` + +#### SSH to your Server + +``` +ssh root@ipaddress +``` +you will be prompt of that password. +type the password you receive in your email + +then it will ask to you to change a new password +just change it to the custom root password you want + +After SSH +you can check that docker command is working by typing + +``` +$root@midascode:~# docker +``` + +#### Set Up Your Laravel Project + +``` +$root@midascode:~# apt-get install git +$root@midascode:~# git clone https://github.com/laravel/laravel +$root@midascode:~# cd laravel +$root@midascode:~/laravel# git checkout develop +$root@midascode:~/laravel/ git submodule add https://github.com/LaraDock/laradock.git +$root@midascode:~/laravel/ cd laradock +``` + +#### Install docker-compose command + +``` +$root@midascode:~/laravel/laradock# curl -L https://github.com/docker/compose/releases/download/1.8.0/run.sh > /usr/local/bin/docker-compose +$root@midascode:~/chmod +x /usr/local/bin/docker-compose +``` + +#### Create Your LaraDock Containers + +``` +$root@midascode:~/laravel/laradock# docker-compose up -d nginx mysql +``` + +#### Go to Your Workspace + +``` +docker-compose exec workspace bash +``` + +#### Install laravel Dependencies, Add .env , generate Key and give proper permission certain folder + +``` +$ root@0e77851d27d3:/var/www/laravel# composer install +$ root@0e77851d27d3:/var/www/laravel# cp .env.example .env +$ root@0e77851d27d3:/var/www/laravel# php artisan key:generate +$ root@0e77851d27d3:/var/www/laravel# exit +$root@midascode:~/laravel/laradock# cd .. +$root@midascode:~/laravel# sudo chmod -R 777 storage bootstrap/cache +``` + +you can then view your laravel site at your ipaddress +for example +``` +192.168.1.1 +``` + +You will see there Laravel Default Welcome Page + +but if you need to view on your custom domain name +which you would. + +#### Using Your Own Domain Name +login to your DNS provider +Godaddy, Namecheap what ever... +And Point the Custom Domain Name Server to + +``` +ns1.digitalocean.com +ns2.digitalocean.com +ns3.digitalocean.com +``` +In Your Digital Ocean Account go to +``` +https://cloud.digitalocean.com/networking/domains +``` +add your domain name and choose the server ip you provision earlier + +#### Serve Site With NGINX (HTTP ONLY) +Go back to command line +``` +$root@midascode:~/laravel/laradock# cd nginx +$root@midascode:~/laravel/laradock/nginx# vim laravel.conf +``` +remove default_server +``` + + listen 80 default_server; + listen [::]:80 default_server ipv6only=on; + +``` + and add server_name (your custom domain) +``` + listen 80; + listen [::]:80 ipv6only=on; + server_name yourdomain.com; +``` + +#### Rebuild Your Nginx +``` +$root@midascode:~/laravel/laradock/nginx# docker-compose down +$root@midascode:~/laravel/laradock/nginx# docker-compose build nginx +``` + +#### Re Run Your Containers MYSQL and NGINX +``` +$root@midascode:~/laravel/laradock/nginx# docker-compose up -d nginx mysql +``` + +###### View Your Site with HTTP ONLY (http://yourdomain.com) + +#### Run Site on SSL with Let's Encrypt Certificate + +###### Note: You need to Use Caddy here Instead of Nginx + +###### To go Caddy Folders and Edit CaddyFile + +``` +$root@midascode:~/laravel/laradock# cd caddy +$root@midascode:~/laravel/laradock/caddy# vim Caddyfile +``` + +Remove 0.0.0.0:80 + +``` +0.0.0.0:80 +root /var/www/laravel/public +``` +and replace with your https://yourdomain.com + +``` +https://yourdomain.com +root /var/www/laravel/public +``` +uncomment tls + +``` +#tls self-signed +``` +and replace self-signed with your email address + +``` +tls midascodebreaker@gmai.com +``` +This is needed Prior to Creating Let's Encypt + +#### Run Your Caddy Container without the -d flag and Generate SSL with Let's Encrypt + +``` +$root@midascode:~/laravel/laradock/caddy# docker-compose up caddy +``` + +you will be prompt here to enter your email... you may enter it or not +``` +Attaching to laradock_mysql_1, laradock_caddy_1 +caddy_1 | Activating privacy features... +caddy_1 | Your sites will be served over HTTPS automatically using Let's Encrypt. +caddy_1 | By continuing, you agree to the Let's Encrypt Subscriber Agreement at: +caddy_1 | https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf +caddy_1 | Activating privacy features... done. +caddy_1 | https://yourdomain.com +caddy_1 | http://yourdomain.com +``` + +After it finish Press Ctrl + C to exit ... + +#### Stop All Containers and ReRun Caddy and Other Containers on Background + +``` +$root@midascode:~/laravel/laradock/caddy# docker-compose down +$root@midascode:~/laravel/laradock/caddy# docker-compose up -d mysql caddy +``` +View your Site in the Browser Securely Using HTTPS (https://yourdomain.com) + +##### Note that Certificate will be Automatically Renew By Caddy + +>References: +> +- [https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04) +- [https://www.digitalocean.com/products/one-click-apps/docker/](https://www.digitalocean.com/products/one-click-apps/docker/) +- [https://docs.docker.com/engine/installation/linux/ubuntulinux/](https://docs.docker.com/engine/installation/linux/ubuntulinux/) +- [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/) +- [https://caddyserver.com/docs/automatic-https](https://caddyserver.com/docs/automatic-https) +- [https://caddyserver.com/docs/tls](https://caddyserver.com/docs/tls) +- [https://caddyserver.com/docs/caddyfile](https://caddyserver.com/docs/caddyfile) + + + + + + + + + + +