diff --git a/.travis.yml b/.travis.yml index f54fc735..887b61ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,9 +33,9 @@ env: - PHP_VERSION=70 BUILD_SERVICE=aerospike - PHP_VERSION=71 BUILD_SERVICE=aerospike - - PHP_VERSION=56 BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq adminer elasticsearch certbot mailhog selenium jenkins proxy proxy2 balancer" - - PHP_VERSION=70 BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq adminer elasticsearch certbot mailhog selenium jenkins proxy proxy2 balancer" - - PHP_VERSION=71 BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq adminer elasticsearch certbot mailhog selenium jenkins proxy proxy2 balancer" + - PHP_VERSION=56 BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq adminer elasticsearch certbot mailhog maildev selenium jenkins proxy proxy2 balancer" + - PHP_VERSION=70 BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq adminer elasticsearch certbot mailhog maildev selenium jenkins proxy proxy2 balancer" + - PHP_VERSION=71 BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq adminer elasticsearch certbot mailhog maildev selenium jenkins proxy proxy2 balancer" - HUGO_VERSION=0.20.2 diff --git a/DOCUMENTATION/content/contributing/index.md b/DOCUMENTATION/content/contributing/index.md index 042a19a5..3c716558 100644 --- a/DOCUMENTATION/content/contributing/index.md +++ b/DOCUMENTATION/content/contributing/index.md @@ -14,7 +14,7 @@ If you have questions about how to use Laradock, please direct your questions to ## Found an Issue If have an issue or you found a typo in the documentation, you can help us by -opnening an [Issue](https://github.com/laradock/laradock/issues). +opening an [Issue](https://github.com/laradock/laradock/issues). **Steps to do before opening an Issue:** @@ -24,7 +24,7 @@ opnening an [Issue](https://github.com/laradock/laradock/issues). If your issue appears to be a bug, and hasn't been reported, then open a new issue. -*This Help us to maximize the effort we can spend fixing issues and adding new +*This helps us maximize the effort we can spend fixing issues and adding new features, by not reporting duplicate issues.* @@ -61,7 +61,7 @@ To update the sidebar or add a new section to it, you can edit this `DOCUMENTATI ## Support new Software (Add new Container) -* Forke the repo and clone the code. +* Fork the repo and clone the code. * Create folder as the software name (example: `mysql` - `nginx`). @@ -81,7 +81,7 @@ To update the sidebar or add a new section to it, you can edit this `DOCUMENTATI ## Edit supported Software (Edit a Container) -* Forke the repo and clone the code. +* Fork the repo and clone the code. * Open the software (container) folder (example: `mysql` - `nginx`). diff --git a/DOCUMENTATION/content/guides/index.md b/DOCUMENTATION/content/guides/index.md index d166604c..ab744750 100644 --- a/DOCUMENTATION/content/guides/index.md +++ b/DOCUMENTATION/content/guides/index.md @@ -565,6 +565,187 @@ Assuming that you are in laradock folder, type: # Running Laravel Dusk Tests +- [Option 1: Without Selenium](#option1-dusk) +- [Option 2: With Selenium](#option2-dusk) + + +## Option 1: Without Selenium + +- [Intro](#option1-dusk-intro) +- [Workspace Setup](#option1-workspace-setup) +- [Application Setup](#option1-application-setup) +- [Choose Chrome Driver Version (Optional)](#option1-choose-chrome-driver-version) +- [Run Dusk Tests](#option1-run-dusk-tests) + + +### Intro + +This is a guide to run Dusk tests in your `workspace` container with headless +google-chrome and chromedriver. It has been tested with Laravel 5.4 and 5.5. + + +### Workspace Setup + +Update your .env with following entries: + +``` +... +# Install Laravel installer bin to setup demo app +WORKSPACE_INSTALL_LARAVEL_INSTALLER=true +... +# Install all the necessary dependencies for running Dusk tests +WORKSPACE_INSTALL_DUSK_DEPS=true +... +``` + +Then run below to build your workspace. + +``` +docker-compose build workspace +``` + + +### Application Setup + +Run a `workspace` container and you will be inside the container at `/var/www` directory. + +``` +docker-compose run workspace bash + +/var/www#> _ +``` + +Create new Laravel application named `dusk-test` and install Laravel Dusk package. + +``` +/var/www> laravel new dusk-test +/var/www> cd dusk-test +/var/www/dusk-test> composer require --dev laravel/dusk +/var/www/dusk-test> php artisan dusk:install +``` + +Create `.env.dusk.local` by copying from `.env` file. + +``` +/var/www/dusk-test> cp .env .env.dusk.local +``` + +Update the `APP_URL` entry in `.env.dusk.local` to local Laravel server. + +``` +APP_URL=http://localhost:8000 +``` + +You will need to run chromedriver with `headless` and `no-sandbox` flag. In Laravel Dusk 2.x it is +already set `headless` so you just need to add `no-sandbox` flag. If you on previous version 1.x, +you will need to update your `DustTestCase#driver` as shown below. + + +``` +addArguments([ + '--disable-gpu', + '--headless', + '--no-sandbox' + ]); + + return RemoteWebDriver::create( + 'http://localhost:9515', DesiredCapabilities::chrome()->setCapability( + ChromeOptions::CAPABILITY, $options + ) + ); + } +} +``` + + +### Choose Chrome Driver Version (Optional) + +You could choose to use either: + +1. Chrome Driver shipped with Laravel Dusk. (Default) +2. Chrome Driver installed in `workspace` container. (Required tweak on DuskTestCase class) + +For Laravel 2.x, you need to update `DuskTestCase#prepare` method if you wish to go with option #2. + +``` + +setPrefix('chromedriver') + ->getProcess() + ->setEnv(static::chromeEnvironment()); + } + + ... +} +``` + + +### Run Dusk Tests + +Run local server in `workspace` container and run Dusk tests. + +``` +# alias to run Laravel server in the background (php artisan serve --quiet &) +/var/www/dusk-test> serve +# alias to run Dusk tests (php artisan dusk) +/var/www/dusk-test> dusk + +PHPUnit 6.4.0 by Sebastian Bergmann and contributors. + +. 1 / 1 (100%) + +Time: 837 ms, Memory: 6.00MB +``` + + +## Option 2: With Selenium + - [Intro](#dusk-intro) - [DNS Setup](#dns-setup) - [Docker Compose Setup](#docker-compose) @@ -572,7 +753,7 @@ Assuming that you are in laradock folder, type: - [Running Laravel Dusk Tests](#running-tests) -## Intro +### Intro Setting up Laravel Dusk tests to run with Laradock appears be something that eludes most Laradock users. This guide is designed to show you how to wire them up to work together. This guide is written with macOS and Linux in mind. As such, @@ -583,7 +764,7 @@ This guide assumes you know how to use a DNS forwarder such as `dnsmasq` or are with editing the `/etc/hosts` file for one-off DNS changes. -## DNS Setup +### DNS Setup According to RFC-2606, only four TLDs are reserved for local testing[^1]: - `.test` @@ -617,7 +798,7 @@ This will ensure that when navigating to `myapp.test`, it will route the request to `127.0.0.1` which will be handled by Nginx in Laradock. -## Docker Compose setup +### Docker Compose setup In order to make the Selenium container talk to the Nginx container appropriately, the `docker-compose.yml` needs to be edited to accommodate this. Make the following changes: @@ -640,7 +821,7 @@ necessary for running Dusk tests. These changes also link the `nginx` environmen variable to the domain you wired up in your hosts file. -## Laravel Dusk Setup +### Laravel Dusk Setup In order to make Laravel Dusk make the proper request to the Selenium container, you have to edit the `DuskTestCase.php` file that's provided on the initial @@ -650,13 +831,13 @@ Remote Web Driver attempts to use to set up the Selenium session. One recommendation for this is to add a separate config option in your `.env.dusk.local` so it's still possible to run your Dusk tests locally should you want to. -### .env.dusk.local +#### .env.dusk.local ``` ... USE_SELENIUM=true ``` -### DuskTestCase.php +#### DuskTestCase.php ```php abstract class DuskTestCase extends BaseTestCase { @@ -677,7 +858,7 @@ abstract class DuskTestCase extends BaseTestCase ``` -## Running Laravel Dusk Tests +### Running Laravel Dusk Tests Now that you have everything set up, to run your Dusk tests, you have to SSH into the workspace container as you normally would: diff --git a/DOCUMENTATION/content/introduction/index.md b/DOCUMENTATION/content/introduction/index.md index 115a79c6..58e35680 100644 --- a/DOCUMENTATION/content/introduction/index.md +++ b/DOCUMENTATION/content/introduction/index.md @@ -97,7 +97,7 @@ Beanstalkd - RabbitMQ - PHP Worker - **Queueing Management:** Beanstalkd Console - RabbitMQ Console - **Random Tools:** -HAProxy - Certbot - Blackfire - Selenium - Jenkins - ElasticSearch - Kibana - Mailhog - Minio - Varnish - Swoole - Laravel Echo... +HAProxy - Certbot - Blackfire - Selenium - Jenkins - ElasticSearch - Kibana - Mailhog - MailDev - Minio - Varnish - Swoole - Laravel Echo... Laradock introduces the **Workspace** Image, as a development environment. It contains a rich set of helpful tools, all pre-configured to work and integrate with almost any combination of Containers and tools you may choose. diff --git a/caddy/Dockerfile b/caddy/Dockerfile index d88fe390..aca00cdb 100644 --- a/caddy/Dockerfile +++ b/caddy/Dockerfile @@ -1,22 +1,17 @@ -FROM alpine:3.5 +FROM golang -MAINTAINER Eric Pfeiffer +MAINTAINER Huadong Zuo -ENV caddy_version=0.10.5 -ARG plugins=http.git +ARG plugins="git" -LABEL caddy_version="$caddy_version" architecture="amd64" +## If you come frome china, please ues it. -RUN apk update \ - && apk upgrade \ - && apk add --no-cache openssh-client git tar curl +# RUN echo "172.217.6.127 golang.org" >> /etc/hosts -RUN curl --silent --show-error --fail --location \ - --header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" -o - \ - "https://caddyserver.com/download/linux/amd64?plugins=${plugins}" \ - | tar --no-same-owner -C /usr/bin/ -xz caddy \ - && mv /usr/bin/caddy /usr/bin/caddy \ - && chmod 0755 /usr/bin/caddy +RUN go get github.com/abiosoft/caddyplug/caddyplug \ + && caddyplug install-caddy \ + && caddyplug install git +RUN caddy --version EXPOSE 80 443 2015 diff --git a/docker-compose.yml b/docker-compose.yml index 2ccb330f..05c91472 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,8 +40,10 @@ services: - INSTALL_IMAGE_OPTIMIZERS=${WORKSPACE_INSTALL_IMAGE_OPTIMIZERS} - INSTALL_IMAGEMAGICK=${WORKSPACE_INSTALL_IMAGEMAGICK} - INSTALL_TERRAFORM=${WORKSPACE_INSTALL_TERRAFORM} + - INSTALL_DUSK_DEPS=${WORKSPACE_INSTALL_DUSK_DEPS} - PUID=${WORKSPACE_PUID} - PGID=${WORKSPACE_PGID} + - CHROME_DRIVER_VERSION=${WORKSPACE_CHROME_DRIVER_VERSION} - NODE_VERSION=${WORKSPACE_NODE_VERSION} - YARN_VERSION=${WORKSPACE_YARN_VERSION} - TZ=${WORKSPACE_TIMEZONE} @@ -548,6 +550,17 @@ services: - frontend - backend +### MailDev Container ####################################### + + maildev: + build: ./maildev + ports: + - "${MAILDEV_HTTP_PORT}:80" + - "${MAILDEV_SMTP_PORT}:25" + networks: + - frontend + - backend + ### Selenium Container ######################################## selenium: diff --git a/env-example b/env-example index c0e4a7a8..64ad6337 100644 --- a/env-example +++ b/env-example @@ -53,8 +53,10 @@ WORKSPACE_INSTALL_PYTHON=false WORKSPACE_INSTALL_IMAGE_OPTIMIZERS=false WORKSPACE_INSTALL_IMAGEMAGICK=false WORKSPACE_INSTALL_TERRAFORM=false +WORKSPACE_INSTALL_DUSK_DEPS=false WORKSPACE_PUID=1000 WORKSPACE_PGID=1000 +WORKSPACE_CHROME_DRIVER_VERSION=2.32 WORKSPACE_NODE_VERSION=stable WORKSPACE_YARN_VERSION=latest WORKSPACE_TIMEZONE=UTC @@ -203,6 +205,11 @@ PMA_PASSWORD=secret PMA_ROOT_PASSWORD=secret PMA_PORT=8080 +### MAILDEV ############################################################################################################ + +MAILDEV_HTTP_PORT=1080 +MAILDEV_SMTP_PORT=25 + ### VARNISH ############################################################################################################ VARNISH_CONFIG=/etc/varnish/default.vcl diff --git a/jenkins/Dockerfile b/jenkins/Dockerfile index 63480c7c..cfcba23f 100644 --- a/jenkins/Dockerfile +++ b/jenkins/Dockerfile @@ -25,8 +25,8 @@ VOLUME /var/jenkins_home # or config file with your custom jenkins Docker image. RUN mkdir -p /usr/share/jenkins/ref/init.groovy.d -ENV TINI_VERSION 0.13.2 -ENV TINI_SHA afbf8de8a63ce8e4f18cb3f34dfdbbd354af68a1 +ENV TINI_VERSION 0.16.1 +ENV TINI_SHA d1cb5d71adc01d47e302ea439d70c79bd0864288 # Use tini as subreaper in Docker container to adopt zombie processes RUN curl -fsSL https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-static-amd64 -o /bin/tini && chmod +x /bin/tini \ @@ -36,10 +36,10 @@ COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-agent-port.groov # jenkins version being bundled in this docker image ARG JENKINS_VERSION -ENV JENKINS_VERSION ${JENKINS_VERSION:-2.32.3} +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.73.2} # jenkins.war checksum, download will be validated using it -ARG JENKINS_SHA=a25b9a314ca9e76f9673da7309e1882e32674223 +ARG JENKINS_SHA=f6d1351beef34d980b32f8c463be505445f637e2fc62156fecd42891c53c97d3 # Can be used to customize where jenkins.war get downloaded from ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war @@ -47,7 +47,7 @@ ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-w # could use ADD but this one does not check Last-Modified header neither does it allow to control checksum # see https://github.com/docker/docker/issues/8331 RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war \ - && echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha1sum -c - + && echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha256sum -c - ENV JENKINS_UC https://updates.jenkins.io RUN chown -R ${user} "$JENKINS_HOME" /usr/share/jenkins/ref @@ -71,7 +71,7 @@ RUN apt-get install -y curl && curl -sSL https://get.docker.com/ | sh RUN usermod -aG docker jenkins # Install Docker-Compose -RUN curl -L "https://github.com/docker/compose/releases/download/1.10.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose +RUN curl -L "https://github.com/docker/compose/releases/download/1.16.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose RUN chmod +x /usr/local/bin/docker-compose diff --git a/maildev/Dockerfile b/maildev/Dockerfile new file mode 100644 index 00000000..4484c832 --- /dev/null +++ b/maildev/Dockerfile @@ -0,0 +1,5 @@ +FROM djfarrelly/maildev + +MAINTAINER Maxime Hélias + +EXPOSE 80 25 diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 56a4ddb8..423c5d6b 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -1,7 +1,7 @@ -FROM postgres:latest +FROM postgres:alpine MAINTAINER Ben M CMD ["postgres"] -EXPOSE 5432 \ No newline at end of file +EXPOSE 5432 diff --git a/workspace/Dockerfile-56 b/workspace/Dockerfile-56 index f70fc829..9ccb62c7 100644 --- a/workspace/Dockerfile-56 +++ b/workspace/Dockerfile-56 @@ -525,6 +525,35 @@ RUN if [ ${INSTALL_TERRAFORM} = true ]; then \ && rm terraform_0.10.6_linux_amd64.zip \ ;fi +##################################### +# Dusk Dependencies: +##################################### +USER root +ARG INSTALL_DUSK_DEPS=false +ENV INSTALL_DUSK_DEPS ${INSTALL_DUSK_DEPS} +RUN if [ ${INSTALL_DUSK_DEPS} = true ]; then \ + # Install required packages + add-apt-repository ppa:ondrej/php \ + && apt-get update \ + && apt-get -y install zip wget unzip xdg-utils \ + libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4 xvfb \ + gtk2-engines-pixbuf xfonts-cyrillic xfonts-100dpi xfonts-75dpi \ + xfonts-base xfonts-scalable x11-apps \ + + # Install Google Chrome + && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \ + && dpkg -i --force-depends google-chrome-stable_current_amd64.deb \ + && apt-get -y -f install \ + && dpkg -i --force-depends google-chrome-stable_current_amd64.deb \ + && rm google-chrome-stable_current_amd64.deb \ + + # Install Chrome Driver + && wget https://chromedriver.storage.googleapis.com/2.31/chromedriver_linux64.zip \ + && unzip chromedriver_linux64.zip \ + && mv chromedriver /usr/local/bin/ \ + && rm chromedriver_linux64.zip \ +;fi + # #-------------------------------------------------------------------------- # Final Touch diff --git a/workspace/Dockerfile-70 b/workspace/Dockerfile-70 index 819d88d5..0daa29fa 100644 --- a/workspace/Dockerfile-70 +++ b/workspace/Dockerfile-70 @@ -618,6 +618,35 @@ RUN if [ ${INSTALL_TERRAFORM} = true ]; then \ && rm terraform_0.10.6_linux_amd64.zip \ ;fi +##################################### +# Dusk Dependencies: +##################################### +USER root +ARG INSTALL_DUSK_DEPS=false +ENV INSTALL_DUSK_DEPS ${INSTALL_DUSK_DEPS} +RUN if [ ${INSTALL_DUSK_DEPS} = true ]; then \ + # Install required packages + add-apt-repository ppa:ondrej/php \ + && apt-get update \ + && apt-get -y install zip wget unzip xdg-utils \ + libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4 xvfb \ + gtk2-engines-pixbuf xfonts-cyrillic xfonts-100dpi xfonts-75dpi \ + xfonts-base xfonts-scalable x11-apps \ + + # Install Google Chrome + && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \ + && dpkg -i --force-depends google-chrome-stable_current_amd64.deb \ + && apt-get -y -f install \ + && dpkg -i --force-depends google-chrome-stable_current_amd64.deb \ + && rm google-chrome-stable_current_amd64.deb \ + + # Install Chrome Driver + && wget https://chromedriver.storage.googleapis.com/2.31/chromedriver_linux64.zip \ + && unzip chromedriver_linux64.zip \ + && mv chromedriver /usr/local/bin/ \ + && rm chromedriver_linux64.zip \ +;fi + # #-------------------------------------------------------------------------- # Final Touch diff --git a/workspace/Dockerfile-71 b/workspace/Dockerfile-71 index 383689d6..ac47e4e6 100644 --- a/workspace/Dockerfile-71 +++ b/workspace/Dockerfile-71 @@ -624,6 +624,32 @@ RUN if [ ${INSTALL_TERRAFORM} = true ]; then \ && rm terraform_0.10.6_linux_amd64.zip \ ;fi +##################################### +# Dusk Dependencies: +##################################### +USER root +ARG CHROME_DRIVER_VERSION=stable +ENV CHROME_DRIVER_VERSION ${CHROME_DRIVER_VERSION} +ARG INSTALL_DUSK_DEPS=false +ENV INSTALL_DUSK_DEPS ${INSTALL_DUSK_DEPS} +RUN if [ ${INSTALL_DUSK_DEPS} = true ]; then \ + add-apt-repository ppa:ondrej/php \ + && apt-get update \ + && apt-get -y install zip wget unzip xdg-utils \ + libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4 xvfb \ + gtk2-engines-pixbuf xfonts-cyrillic xfonts-100dpi xfonts-75dpi \ + xfonts-base xfonts-scalable x11-apps \ + && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \ + && dpkg -i --force-depends google-chrome-stable_current_amd64.deb \ + && apt-get -y -f install \ + && dpkg -i --force-depends google-chrome-stable_current_amd64.deb \ + && rm google-chrome-stable_current_amd64.deb \ + && wget https://chromedriver.storage.googleapis.com/${CHROME_DRIVER_VERSION}/chromedriver_linux64.zip \ + && unzip chromedriver_linux64.zip \ + && mv chromedriver /usr/local/bin/ \ + && rm chromedriver_linux64.zip \ +;fi + # #-------------------------------------------------------------------------- # Final Touch diff --git a/workspace/aliases.sh b/workspace/aliases.sh index 3e9bbb6f..29fc22de 100644 --- a/workspace/aliases.sh +++ b/workspace/aliases.sh @@ -69,6 +69,7 @@ alias migrate="php artisan migrate" alias refresh="php artisan migrate:refresh" alias rollback="php artisan migrate:rollback" alias seed="php artisan:seed" +alias serve="php artisan serve --quiet &" alias phpunit="./vendor/bin/phpunit" alias pu="phpunit" @@ -88,6 +89,9 @@ alias reload="source ~/.aliases && echo \"$COL_GREEN ==> Aliases Reloaded... $CO alias run="npm run" alias tree="xtree" +# Xvfb +alias xvfb="Xvfb -ac :0 -screen 0 1024x768x16 &" + # requires installation of 'https://www.npmjs.com/package/npms-cli' alias npms="npms search" # requires installation of 'https://www.npmjs.com/package/package-menu-cli'