Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 83 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,86 @@ In this section you can find all commands supported by harbor:

## SSH keys ##

To use ssh keys in php container, copy your keys to ./docker/php/ssh. You have to restart container after adding keys. SSH keys may be required for some git repositories.
To use ssh keys in php container, copy your keys to ./docker/php/ssh. You have to restart container after adding keys. SSH keys may be required for some git repositories.

## Laravel Dusk implementation (via selenium container) ##

Read more about Laravel Dusk here: https://laravel.com/docs/7.x/dusk

**1. `harbor stop` - stop all containers**

**2. uncomment following section of code in your docker-compose.yml:**

```
# selenium:
# image: selenium/standalone-chrome:3.11.0-antimony
# volumes:
# - /dev/shm:/dev/shm
# networks:
# - harbornet
```

**3. `harbor start` - start containers. Make sure selenium/standalone-chrome is running with command `docker ps`**

**4. create copy of yours .env to .env.dusk.local and modify .env.dusk.local with these modifications:**

```
APP_DEBUG=false
APP_URL=http://nginx:80
DB_HOST=testing
```

**5. install Laravel Dusk**

We are using selenium as driver for Dusk, so therefore our implementation is combination of these instructions:
https://laravel.com/docs/7.x/dusk#installation and https://laravel.com/docs/7.x/dusk#using-other-browsers

`harbor composer require --dev laravel/dusk` - first install Laravel Dusk package into your project via composer

`harbor artisan dusk:install` - will prepare some directories, files and some basic test in your Laravel project

**6. alter prepare() and driver() method in tests/DuskTestCase.php to utilize selenium container**

```

/**
* Prepare for Dusk test execution.
*
* @beforeClass
* @return void
*/
public static function prepare()
{
// static::startChromeDriver();
}

/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
protected function driver()
{
$options = (new ChromeOptions)->addArguments([
'--window-size=1366,768',
'--disable-gpu',
'--headless',
'--no-sandbox',
'--ignore-ssl-errors',
]);

return RemoteWebDriver::create(
'http://selenium:4444/wd/hub',
DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY,
$options
)
);
}
```

**7. test Laravel Dusk implementation**

`harbor artisan dusk` - will run Dusk test

In the case test failed - you can look in tests/Browser/screenshots for failure screenshots.
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ services:
- redisdata:/data
networks:
- harbornet
# Uncomment selenium section if you want to use selenium (for example for Laravel Dusk ) for your project
# selenium:
# image: selenium/standalone-chrome:3.11.0-antimony
# volumes:
# - /dev/shm:/dev/shm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need this volume?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that I found this as recommendation for selenium implementation. Look for example here:
https://sondnm.github.io/blog/2018/09/08/i-just-learnt-about-/dev/shm/ - selenium will be able to use host shared memory ( in cases container consumes too much memory, it can use host shared memory )

# networks:
# - harbornet
networks:
harbornet:
driver: "bridge"
Expand Down