Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Arkadius Jonczek 2017-10-18 14:41:20 +02:00
commit 49e48edefd
14 changed files with 326 additions and 37 deletions

View File

@ -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

View File

@ -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`).

View File

@ -565,6 +565,187 @@ Assuming that you are in laradock folder, type:
<a name="Laravel-Dusk"></a>
# Running Laravel Dusk Tests
- [Option 1: Without Selenium](#option1-dusk)
- [Option 2: With Selenium](#option2-dusk)
<a name="option1-dusk"></a>
## 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)
<a name="option1-dusk-intro"></a>
### 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.
<a name="option1-workspace-setup"></a>
### 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
```
<a name="option1-application-setup"></a>
### 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.
```
<?php
...
abstract class DuskTestCase extends BaseTestCase
{
...
/**
* Update chrome driver with below flags
*/
protected function driver()
{
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
'--headless',
'--no-sandbox'
]);
return RemoteWebDriver::create(
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
)
);
}
}
```
<a name="option1-choose-chrome-driver-version"></a>
### 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.
```
<?php
...
abstract class DuskTestCase extends BaseTestCase
{
...
public static function prepare()
{
// Only add this line if you wish to use chrome driver installed in workspace container.
// You might want to read the file path from env file.
static::useChromedriver('/usr/local/bin/chromedriver');
static::startChromeDriver();
}
```
For Laravel 1.x, you need to add `DuskTestCase#buildChromeProcess` method if you wish to go with option #2.
```
<?php
...
use Symfony\Component\Process\ProcessBuilder;
abstract class DuskTestCase extends BaseTestCase
{
...
/**
* Only add this method if you wish to use chrome driver installed in workspace container
*/
protected static function buildChromeProcess()
{
return (new ProcessBuilder())
->setPrefix('chromedriver')
->getProcess()
->setEnv(static::chromeEnvironment());
}
...
}
```
<a name="option1-run-dusk-tests"></a>
### 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
```
<a name="option2-dusk"></a>
## 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)
<a name="dusk-intro"></a>
## 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.
<a name="dns-setup"></a>
## 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.
<a name="docker-compose"></a>
## 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.
<a name="laravel-dusk-setup"></a>
## 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
```
<a name="running-tests"></a>
## 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:

View File

@ -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.

View File

@ -1,22 +1,17 @@
FROM alpine:3.5
FROM golang
MAINTAINER Eric Pfeiffer <computerfr33k@users.noreply.github.com>
MAINTAINER Huadong Zuo <admin@zuohuadong.cn>
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

View File

@ -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:

View File

@ -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

View File

@ -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

5
maildev/Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM djfarrelly/maildev
MAINTAINER Maxime Hélias <maximehelias16@gmail.com>
EXPOSE 80 25

View File

@ -1,4 +1,4 @@
FROM postgres:latest
FROM postgres:alpine
MAINTAINER Ben M <git@bmagg.com>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'