Skip to content

Commit 49e48ed

Browse files
Merge remote-tracking branch 'upstream/master'
2 parents 182386b + a5c505b commit 49e48ed

14 files changed

Lines changed: 326 additions & 37 deletions

File tree

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ env:
3333
- PHP_VERSION=70 BUILD_SERVICE=aerospike
3434
- PHP_VERSION=71 BUILD_SERVICE=aerospike
3535

36-
- PHP_VERSION=56 BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq adminer elasticsearch certbot mailhog selenium jenkins proxy proxy2 balancer"
37-
- PHP_VERSION=70 BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq adminer elasticsearch certbot mailhog selenium jenkins proxy proxy2 balancer"
38-
- PHP_VERSION=71 BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq adminer elasticsearch certbot mailhog selenium jenkins proxy proxy2 balancer"
36+
- PHP_VERSION=56 BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq adminer elasticsearch certbot mailhog maildev selenium jenkins proxy proxy2 balancer"
37+
- PHP_VERSION=70 BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq adminer elasticsearch certbot mailhog maildev selenium jenkins proxy proxy2 balancer"
38+
- PHP_VERSION=71 BUILD_SERVICE="memcached beanstalkd beanstalkd-console rabbitmq adminer elasticsearch certbot mailhog maildev selenium jenkins proxy proxy2 balancer"
3939

4040
- HUGO_VERSION=0.20.2
4141

DOCUMENTATION/content/contributing/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ If you have questions about how to use Laradock, please direct your questions to
1414
## Found an Issue
1515

1616
If have an issue or you found a typo in the documentation, you can help us by
17-
opnening an [Issue](https://github.com/laradock/laradock/issues).
17+
opening an [Issue](https://github.com/laradock/laradock/issues).
1818

1919
**Steps to do before opening an Issue:**
2020

@@ -24,7 +24,7 @@ opnening an [Issue](https://github.com/laradock/laradock/issues).
2424

2525
If your issue appears to be a bug, and hasn't been reported, then open a new issue.
2626

27-
*This Help us to maximize the effort we can spend fixing issues and adding new
27+
*This helps us maximize the effort we can spend fixing issues and adding new
2828
features, by not reporting duplicate issues.*
2929

3030

@@ -61,7 +61,7 @@ To update the sidebar or add a new section to it, you can edit this `DOCUMENTATI
6161

6262
## Support new Software (Add new Container)
6363

64-
* Forke the repo and clone the code.
64+
* Fork the repo and clone the code.
6565

6666
* Create folder as the software name (example: `mysql` - `nginx`).
6767

@@ -81,7 +81,7 @@ To update the sidebar or add a new section to it, you can edit this `DOCUMENTATI
8181

8282
## Edit supported Software (Edit a Container)
8383

84-
* Forke the repo and clone the code.
84+
* Fork the repo and clone the code.
8585

8686
* Open the software (container) folder (example: `mysql` - `nginx`).
8787

DOCUMENTATION/content/guides/index.md

Lines changed: 188 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -565,14 +565,195 @@ Assuming that you are in laradock folder, type:
565565
<a name="Laravel-Dusk"></a>
566566
# Running Laravel Dusk Tests
567567

568+
- [Option 1: Without Selenium](#option1-dusk)
569+
- [Option 2: With Selenium](#option2-dusk)
570+
571+
<a name="option1-dusk"></a>
572+
## Option 1: Without Selenium
573+
574+
- [Intro](#option1-dusk-intro)
575+
- [Workspace Setup](#option1-workspace-setup)
576+
- [Application Setup](#option1-application-setup)
577+
- [Choose Chrome Driver Version (Optional)](#option1-choose-chrome-driver-version)
578+
- [Run Dusk Tests](#option1-run-dusk-tests)
579+
580+
<a name="option1-dusk-intro"></a>
581+
### Intro
582+
583+
This is a guide to run Dusk tests in your `workspace` container with headless
584+
google-chrome and chromedriver. It has been tested with Laravel 5.4 and 5.5.
585+
586+
<a name="option1-workspace-setup"></a>
587+
### Workspace Setup
588+
589+
Update your .env with following entries:
590+
591+
```
592+
...
593+
# Install Laravel installer bin to setup demo app
594+
WORKSPACE_INSTALL_LARAVEL_INSTALLER=true
595+
...
596+
# Install all the necessary dependencies for running Dusk tests
597+
WORKSPACE_INSTALL_DUSK_DEPS=true
598+
...
599+
```
600+
601+
Then run below to build your workspace.
602+
603+
```
604+
docker-compose build workspace
605+
```
606+
607+
<a name="option1-application-setup"></a>
608+
### Application Setup
609+
610+
Run a `workspace` container and you will be inside the container at `/var/www` directory.
611+
612+
```
613+
docker-compose run workspace bash
614+
615+
/var/www#> _
616+
```
617+
618+
Create new Laravel application named `dusk-test` and install Laravel Dusk package.
619+
620+
```
621+
/var/www> laravel new dusk-test
622+
/var/www> cd dusk-test
623+
/var/www/dusk-test> composer require --dev laravel/dusk
624+
/var/www/dusk-test> php artisan dusk:install
625+
```
626+
627+
Create `.env.dusk.local` by copying from `.env` file.
628+
629+
```
630+
/var/www/dusk-test> cp .env .env.dusk.local
631+
```
632+
633+
Update the `APP_URL` entry in `.env.dusk.local` to local Laravel server.
634+
635+
```
636+
APP_URL=http://localhost:8000
637+
```
638+
639+
You will need to run chromedriver with `headless` and `no-sandbox` flag. In Laravel Dusk 2.x it is
640+
already set `headless` so you just need to add `no-sandbox` flag. If you on previous version 1.x,
641+
you will need to update your `DustTestCase#driver` as shown below.
642+
643+
644+
```
645+
<?php
646+
647+
...
648+
649+
abstract class DuskTestCase extends BaseTestCase
650+
{
651+
...
652+
653+
/**
654+
* Update chrome driver with below flags
655+
*/
656+
protected function driver()
657+
{
658+
$options = (new ChromeOptions)->addArguments([
659+
'--disable-gpu',
660+
'--headless',
661+
'--no-sandbox'
662+
]);
663+
664+
return RemoteWebDriver::create(
665+
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
666+
ChromeOptions::CAPABILITY, $options
667+
)
668+
);
669+
}
670+
}
671+
```
672+
673+
<a name="option1-choose-chrome-driver-version"></a>
674+
### Choose Chrome Driver Version (Optional)
675+
676+
You could choose to use either:
677+
678+
1. Chrome Driver shipped with Laravel Dusk. (Default)
679+
2. Chrome Driver installed in `workspace` container. (Required tweak on DuskTestCase class)
680+
681+
For Laravel 2.x, you need to update `DuskTestCase#prepare` method if you wish to go with option #2.
682+
683+
```
684+
685+
<?php
686+
687+
...
688+
abstract class DuskTestCase extends BaseTestCase
689+
{
690+
...
691+
public static function prepare()
692+
{
693+
// Only add this line if you wish to use chrome driver installed in workspace container.
694+
// You might want to read the file path from env file.
695+
static::useChromedriver('/usr/local/bin/chromedriver');
696+
697+
static::startChromeDriver();
698+
}
699+
```
700+
701+
For Laravel 1.x, you need to add `DuskTestCase#buildChromeProcess` method if you wish to go with option #2.
702+
703+
```
704+
<?php
705+
706+
...
707+
use Symfony\Component\Process\ProcessBuilder;
708+
709+
abstract class DuskTestCase extends BaseTestCase
710+
{
711+
...
712+
713+
/**
714+
* Only add this method if you wish to use chrome driver installed in workspace container
715+
*/
716+
protected static function buildChromeProcess()
717+
{
718+
return (new ProcessBuilder())
719+
->setPrefix('chromedriver')
720+
->getProcess()
721+
->setEnv(static::chromeEnvironment());
722+
}
723+
724+
...
725+
}
726+
```
727+
728+
<a name="option1-run-dusk-tests"></a>
729+
### Run Dusk Tests
730+
731+
Run local server in `workspace` container and run Dusk tests.
732+
733+
```
734+
# alias to run Laravel server in the background (php artisan serve --quiet &)
735+
/var/www/dusk-test> serve
736+
# alias to run Dusk tests (php artisan dusk)
737+
/var/www/dusk-test> dusk
738+
739+
PHPUnit 6.4.0 by Sebastian Bergmann and contributors.
740+
741+
. 1 / 1 (100%)
742+
743+
Time: 837 ms, Memory: 6.00MB
744+
```
745+
746+
<a name="option2-dusk"></a>
747+
## Option 2: With Selenium
748+
568749
- [Intro](#dusk-intro)
569750
- [DNS Setup](#dns-setup)
570751
- [Docker Compose Setup](#docker-compose)
571752
- [Laravel Dusk Setup](#laravel-dusk-setup)
572753
- [Running Laravel Dusk Tests](#running-tests)
573754

574755
<a name="dusk-intro"></a>
575-
## Intro
756+
### Intro
576757
Setting up Laravel Dusk tests to run with Laradock appears be something that
577758
eludes most Laradock users. This guide is designed to show you how to wire them
578759
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
583764
with editing the `/etc/hosts` file for one-off DNS changes.
584765

585766
<a name="dns-setup"></a>
586-
## DNS Setup
767+
### DNS Setup
587768
According to RFC-2606, only four TLDs are reserved for local testing[^1]:
588769

589770
- `.test`
@@ -617,7 +798,7 @@ This will ensure that when navigating to `myapp.test`, it will route the
617798
request to `127.0.0.1` which will be handled by Nginx in Laradock.
618799

619800
<a name="docker-compose"></a>
620-
## Docker Compose setup
801+
### Docker Compose setup
621802
In order to make the Selenium container talk to the Nginx container appropriately,
622803
the `docker-compose.yml` needs to be edited to accommodate this. Make the following
623804
changes:
@@ -640,7 +821,7 @@ necessary for running Dusk tests. These changes also link the `nginx` environmen
640821
variable to the domain you wired up in your hosts file.
641822

642823
<a name="laravel-dusk-setup"></a>
643-
## Laravel Dusk Setup
824+
### Laravel Dusk Setup
644825

645826
In order to make Laravel Dusk make the proper request to the Selenium container,
646827
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.
650831
One recommendation for this is to add a separate config option in your `.env.dusk.local`
651832
so it's still possible to run your Dusk tests locally should you want to.
652833

653-
### .env.dusk.local
834+
#### .env.dusk.local
654835
```
655836
...
656837
USE_SELENIUM=true
657838
```
658839
659-
### DuskTestCase.php
840+
#### DuskTestCase.php
660841
```php
661842
abstract class DuskTestCase extends BaseTestCase
662843
{
@@ -677,7 +858,7 @@ abstract class DuskTestCase extends BaseTestCase
677858
```
678859

679860
<a name="running-tests"></a>
680-
## Running Laravel Dusk Tests
861+
### Running Laravel Dusk Tests
681862

682863
Now that you have everything set up, to run your Dusk tests, you have to SSH
683864
into the workspace container as you normally would:

DOCUMENTATION/content/introduction/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Beanstalkd - RabbitMQ - PHP Worker
9797
- **Queueing Management:**
9898
Beanstalkd Console - RabbitMQ Console
9999
- **Random Tools:**
100-
HAProxy - Certbot - Blackfire - Selenium - Jenkins - ElasticSearch - Kibana - Mailhog - Minio - Varnish - Swoole - Laravel Echo...
100+
HAProxy - Certbot - Blackfire - Selenium - Jenkins - ElasticSearch - Kibana - Mailhog - MailDev - Minio - Varnish - Swoole - Laravel Echo...
101101

102102
Laradock introduces the **Workspace** Image, as a development environment.
103103
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.

caddy/Dockerfile

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
FROM alpine:3.5
1+
FROM golang
22

3-
MAINTAINER Eric Pfeiffer <computerfr33k@users.noreply.github.com>
3+
MAINTAINER Huadong Zuo <admin@zuohuadong.cn>
44

5-
ENV caddy_version=0.10.5
6-
ARG plugins=http.git
5+
ARG plugins="git"
76

8-
LABEL caddy_version="$caddy_version" architecture="amd64"
7+
## If you come frome china, please ues it.
98

10-
RUN apk update \
11-
&& apk upgrade \
12-
&& apk add --no-cache openssh-client git tar curl
9+
# RUN echo "172.217.6.127 golang.org" >> /etc/hosts
1310

14-
RUN curl --silent --show-error --fail --location \
15-
--header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" -o - \
16-
"https://caddyserver.com/download/linux/amd64?plugins=${plugins}" \
17-
| tar --no-same-owner -C /usr/bin/ -xz caddy \
18-
&& mv /usr/bin/caddy /usr/bin/caddy \
19-
&& chmod 0755 /usr/bin/caddy
11+
RUN go get github.com/abiosoft/caddyplug/caddyplug \
12+
&& caddyplug install-caddy \
13+
&& caddyplug install git
14+
RUN caddy --version
2015

2116
EXPOSE 80 443 2015
2217

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ services:
4040
- INSTALL_IMAGE_OPTIMIZERS=${WORKSPACE_INSTALL_IMAGE_OPTIMIZERS}
4141
- INSTALL_IMAGEMAGICK=${WORKSPACE_INSTALL_IMAGEMAGICK}
4242
- INSTALL_TERRAFORM=${WORKSPACE_INSTALL_TERRAFORM}
43+
- INSTALL_DUSK_DEPS=${WORKSPACE_INSTALL_DUSK_DEPS}
4344
- PUID=${WORKSPACE_PUID}
4445
- PGID=${WORKSPACE_PGID}
46+
- CHROME_DRIVER_VERSION=${WORKSPACE_CHROME_DRIVER_VERSION}
4547
- NODE_VERSION=${WORKSPACE_NODE_VERSION}
4648
- YARN_VERSION=${WORKSPACE_YARN_VERSION}
4749
- TZ=${WORKSPACE_TIMEZONE}
@@ -548,6 +550,17 @@ services:
548550
- frontend
549551
- backend
550552

553+
### MailDev Container #######################################
554+
555+
maildev:
556+
build: ./maildev
557+
ports:
558+
- "${MAILDEV_HTTP_PORT}:80"
559+
- "${MAILDEV_SMTP_PORT}:25"
560+
networks:
561+
- frontend
562+
- backend
563+
551564
### Selenium Container ########################################
552565

553566
selenium:

env-example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ WORKSPACE_INSTALL_PYTHON=false
5353
WORKSPACE_INSTALL_IMAGE_OPTIMIZERS=false
5454
WORKSPACE_INSTALL_IMAGEMAGICK=false
5555
WORKSPACE_INSTALL_TERRAFORM=false
56+
WORKSPACE_INSTALL_DUSK_DEPS=false
5657
WORKSPACE_PUID=1000
5758
WORKSPACE_PGID=1000
59+
WORKSPACE_CHROME_DRIVER_VERSION=2.32
5860
WORKSPACE_NODE_VERSION=stable
5961
WORKSPACE_YARN_VERSION=latest
6062
WORKSPACE_TIMEZONE=UTC
@@ -203,6 +205,11 @@ PMA_PASSWORD=secret
203205
PMA_ROOT_PASSWORD=secret
204206
PMA_PORT=8080
205207

208+
### MAILDEV ############################################################################################################
209+
210+
MAILDEV_HTTP_PORT=1080
211+
MAILDEV_SMTP_PORT=25
212+
206213
### VARNISH ############################################################################################################
207214

208215
VARNISH_CONFIG=/etc/varnish/default.vcl

0 commit comments

Comments
 (0)