To add an image (software), just edit the `docker-compose.yml` and add your container details, to do so you need to be familiar with the [docker compose file syntax](https://docs.docker.com/compose/compose-file/).
<br>
<aname="View-the-Log-files"></a>
## View the Log files
The NGINX Log file is stored in the `logs/nginx` directory.
However to view the logs of all the other containers (MySQL, PHP-FPM,...) you can run this:
>The PHP-FPM is responsible for serving your application code, you don't have to change the PHP-CLI version if you are planning to run your application on different PHP-FPM version.
>Note: it's not very essential to edit the PHP-CLI version. The PHP-CLI is only used for the Artisan Commands & Composer. It doesn't serve your Application code, this is the PHP-FPM job.
The PHP-CLI is installed in the Workspace container. To change the PHP-CLI version you need to simply change the `PHP_VERSION` in the .env file as follow:
For information on how to configure xDebug with your IDE and work it out, check this [Repository](https://github.com/LarryEitel/laravel-laradock-phpstorm) or follow up on the next section if you use linux and PhpStorm.
By installing xDebug, you are enabling it to run on startup by default.
To control the behavior of xDebug (in the `php-fpm` Container), you can run the following commands from the Laradock root folder, (at the same prompt where you run docker-compose):
- Stop xDebug from running by default: `.php-fpm/xdebug stop`.
- Start xDebug by default: `.php-fpm/xdebug start`.
Note: If `.php-fpm/xdebug` doesn't execute and gives `Permission Denied` error the problem can be that file `xdebug` doesn't have execution access. This can be fixed by running `chmod` command with desired access permissions.
SonarQube® is an automatic code review tool to detect bugs, vulnerabilities and code smells in your code. It can integrate with your existing workflow to enable continuous code inspection across your project branches and pull requests.
In your new production `docker-compose.yml` file, you should include only the containers you are planning to run in production (usage example: `docker-compose -f production-docker-compose.yml up -d nginx mysql redis ...`).
Note: The Database (MySQL/MariaDB/...) ports should not be forwarded on production, because Docker will automatically publish the port on the host unless specifically told not to. Forwarding these ports on production is quite insecure - so make sure to remove these lines:
Note: Should add `--user=laradock` (example `docker-compose exec --user=laradock workspace bash`) to have files created as your host's user to prevent issue owner of log file will be changed to root then laravel website cannot write on log file if using rotated log and new log file not existed
1 - Create a suitable configuration file (for example named `laravel-worker.conf`) for Laravel Queue Worker in `php-worker/supervisord.d/` by simply copying from `laravel-worker.conf.example`
Most of the time, when you start Laradock, it'll automatically start workspace container with cron inside, along with setting to run `schedule:run` command every minute.
2. Using Supervisord in php-worker to run `schedule:run`.
This way is suggested when you don't want to start workspace in production environment.
* Comment out cron setting in workspace container, file `workspace/crontab/laradock`
* Create a suitable configuration file (for ex., named `laravel-scheduler.conf`) for Laravel Scheduler in `php-worker/supervisord.d/` by simply copying from `laravel-scheduler.conf.example`
1. Add the following settings to your `webpack.mix.js` file. Please refer to Browsersync [Options](https://browsersync.io/docs/options) page for more options.
proxy: 'nginx' // replace with your web server container
})
```
2. Run `npm run watch` within your `workspace` container.
3. Open your browser and visit address `http://localhost:[WORKSPACE_BROWSERSYNC_HOST_PORT]`. It will refresh the page automatically whenever you edit any source file in your project.
4. If you wish to access Browsersync UI for your project, visit address `http://localhost:[WORKSPACE_BROWSERSYNC_UI_HOST_PORT]`.
3. You can use environment to configure Metabase container. See docs in: [Running Metabase on Docker](https://www.metabase.com/docs/v0.12.0/operations-guide/running-metabase-on-docker.html)
(To enter container as root type `docker-compose exec --user root jenkins bash`).
4) Install some plugins.
5) Create your first Admin user, or continue as Admin.
Note: to add user go to `http://localhost:8090/securityRealm/addUser` and to restart it from the web app visit `http://localhost:8090/restart`.
You may wanna change the default security configuration, so go to `http://localhost:8090/configureSecurity/` under Authorization and choosing "Anyone can do anything" or "Project-based Matrix Authorization Strategy" or anything else.
1. First make sure you run the Redis Container (`redis`) with the `docker-compose up` command.
```bash
docker-compose up -d redis
```
> To execute redis commands, enter the redis container first `docker-compose exec redis bash` then enter the `redis-cli`.
2. Open your Laravel's `.env` file and set the `REDIS_HOST` to `redis`
```env
REDIS_HOST=redis
```
If you're using Laravel, and you don't find the `REDIS_HOST` variable in your `.env` file. Go to the database configuration file `config/database.php` and replace the default `127.0.0.1` IP with `redis` for Redis like this:
3. To enable Redis Caching and/or for Sessions Management. Also from the `.env` file set `CACHE_DRIVER` and `SESSION_DRIVER` to `redis` instead of the default `file`.
```env
CACHE_DRIVER=redis
SESSION_DRIVER=redis
```
4. Finally make sure you have the `predis/predis` package `(~1.0)` installed via Composer:
```bash
composer require predis/predis:^1.0
```
5. You can manually test it from Laravel with this code:
Nginx is on port 80 or 443. Nginx sends request through varnish server and varnish server sends request back to nginx on port 81 (external port is defined in `VARNISH_BACKEND_PORT`).
The idea was taken from this [post](https://www.linode.com/docs/websites/varnish/use-varnish-and-nginx-to-serve-wordpress-over-ssl-and-http-on-debian-8/)
2. Open your browser and visit the localhost on port **8081**: `http://localhost:8081`, use server: "mysql", user: "default" and password: "secret for the default mysql setup.
- You can load plugins in the `ADM_PLUGINS` variable in the `.env` file. If a plugin requires parameters to work correctly you will need to add a custom file to the container. [Find more info in section 'Loading plugins'](https://hub.docker.com/_/adminer).
- You can choose a design in the `ADM_DESIGN` variable in the `.env` file. [Find more info in section 'Choosing a design'](https://hub.docker.com/_/adminer).
- You can specify the default host with the `ADM_DEFAULT_SERVER` variable in the `.env` file. This is useful if you are connecting to an external server or a docker container named something other than the default `mysql`.
2. Configure Laravel to connect to that container by editing the `config/queue.php` config file.
* first set `beanstalkd` as default queue driver
* set the queue host to beanstalkd : `QUEUE_HOST=beanstalkd`
*beanstalkd is now available on default port `11300`.*
3. Require the dependency package [pda/pheanstalk](https://github.com/pda/pheanstalk) using composer.
Optionally you can use the Beanstalkd Console Container to manage your Queues from a web interface.
* Run the Beanstalkd Console Container:
```bash
docker-compose up -d beanstalkd-console
```
* Open your browser and visit `http://localhost:2080/`
_Note: You can customize the port on which beanstalkd console is listening by changing `BEANSTALKD_CONSOLE_HOST_PORT` in `.env`. The default value is *2080*._
You can set custom confluence version in `CONFLUENCE_VERSION`. [Find more info in section 'Versioning'](https://hub.docker.com/r/atlassian/confluence-server/)
The RethinkDB is an open-source Database for Real-time Web ([RethinkDB](https://rethinkdb.com/)).
A package ([Laravel RethinkDB](https://github.com/duxet/laravel-rethinkdb)) is being developed and was released a version for Laravel 5.2 (experimental).
4 - To start using eb cli inside the container, initialize your project first by doing 'eb init'. Read the [aws eb cli](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-configuration.html) docs for more details.
1 - Boot the container `docker-compose up -d graylog`
2 - Open your Laravel's `.env` file and set the `GRAYLOG_PASSWORD` to some passsword, and `GRAYLOG_SHA256_PASSWORD` to the sha256 representation of your password (`GRAYLOG_SHA256_PASSWORD` is what matters, `GRAYLOG_PASSWORD` is just a reminder of your password).
> Your password must be at least 16 characters long
> You can generate sha256 of some password with the following command `echo -n somesupersecretpassword | sha256sum`
2 - You need to change the `docker-compose.yml` file to match the Traefik needs. If you want to use Traefik, you must not expose the ports of each container to the internet, but specify some labels.
1 - Configure Tarantool Port and Tarantool Admin Port using environment variables: `TARANTOOL_PORT` and `TARANTOOL_ADMIN_PORT`. Default ports are 3301 and 8002.
2 - Run the Tarantool and Tarantool Admin tool using `docker-compose up`command:
3 - The NGINX sites include a default config file for your Symfony project `symfony.conf.example`, so edit it and make sure the `root` is pointing to your project `web` directory.
To change the timezone for the `workspace` container, modify the `TZ` build argument in the Docker Compose file to one in the [TZ database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
For example, if I want the timezone to be `New York`:
```yml
workspace:
build:
context: ./workspace
args:
- TZ=America/New_York
...
```
We also recommend [setting the timezone in Laravel](http://www.camroncade.com/managing-timezones-with-laravel/).
MySQL 8.0 is a development release. You may prefer to use the latest stable version, or an even older release. If you wish, you can change the MySQL image that is used.
Open up your .env file and set the `MYSQL_VERSION` variable to the version you would like to install.
```
MYSQL_VERSION=5.7
```
Available versions are: 5.5, 5.6, 5.7, 8.0, or latest. See https://store.docker.com/images/mysql for more information.
Create `createdb.sql` from `mysql/docker-entrypoint-initdb.d/createdb.sql.example` in `mysql/docker-entrypoint-initdb.d/*` and add your SQL syntax as follow:
```sql
CREATE DATABASE IF NOT EXISTS `your_db_1` COLLATE 'utf8_general_ci' ;
Modify the `mysql/my.cnf` file to set your port number, `1234` is used as an example.
```
[mysqld]
port=1234
```
If you need <ahref="#MySQL-access-from-host">MySQL access from your host</a>, do not forget to change the internal port number (`"3306:3306"` -> `"3306:1234"`) in the docker-compose configuration file.
Enabling Global Composer Install during the build for the container allows you to get your composer requirements installed and available in the container after the build is done.
A `.npmrc` file is included in the `workspace` folder if you need to utilise this globally. This is copied automatically into the root and laradock user's folders on build.
pnpm uses hard links and symlinks to save one version of a module only ever once on a disk. When using npm or Yarn for example, if you have 100 projects using the same version of lodash, you will have 100 copies of lodash on disk. With pnpm, lodash will be saved in a single place on the disk and a hard link will put it into the node_modules where it should be installed.
As a result, you save gigabytes of space on your disk and you have a lot faster installations! If you'd like more details about the unique node_modules structure that pnpm creates and why it works fine with the Node.js ecosystem.
More info here: https://pnpm.js.org/en/motivation
1 - Open the `.env` file
2 - Search for the `WORKSPACE_INSTALL_NODE` and `WORKSPACE_INSTALL_PNPM` argument under the Workspace Container and set it to `true`
3 - Re-build the container `docker-compose build workspace`
Yarn is a new package manager for JavaScript. It is so faster than npm, which you can find [here](http://yarnpkg.com/en/compare).To install NodeJS and [Yarn](https://yarnpkg.com/) in the Workspace container:
Poppler is a PDF rendering library based on Xpdf PDF viewer.
This package contains command line utilities (based on Poppler) for getting information of PDF documents, convert them to other formats, or manipulate them:
* pdfdetach -- lists or extracts embedded files (attachments)
* pdffonts -- font analyzer
* pdfimages -- image extractor
* pdfinfo -- document information
* pdfseparate -- page extraction tool
* pdfsig -- verifies digital signatures
* pdftocairo -- PDF to PNG/JPEG/PDF/PS/EPS/SVG converter using Cairo
* pdftohtml -- PDF to HTML converter
* pdftoppm -- PDF to PPM/PNG/JPEG image converter
* pdftops -- PDF to PostScript (PS) converter
* pdftotext -- text extraction
* pdfunite -- document merging tool
To install `poppler-utils` [(more here)](https://packages.debian.org/sid/poppler-utils) in any of the `workspace/php-fpm/php-worker/laravel-horizon` container
1 - Open the `.env` file
2 - Search for the `WORKSPACE_INSTALL_POPPLER_UTILS` argument under the Workspace Container and set it to `true`
3 - Search for the `PHP_FPM_INSTALL_POPPLER_UTILS` argument under the Workspace Container and set it to `true`
4 - Search for the `PHP_WORKER_INSTALL_POPPLER_UTILS` argument under the Workspace Container and set it to `true`
5 - Search for the `LARAVEL_HORIZON_INSTALL_POPPLER_UTILS` argument under the Workspace Container and set it to `true`
Linuxbrew is a package manager for Linux. It is the Linux version of MacOS Homebrew and can be found [here](http://linuxbrew.sh). To install Linuxbrew in the Workspace container:
**PS** Don't forget to install the binary in the `php-fpm` container too by applying the same steps above to its container, otherwise you'll get an error when running the `php-ffmpeg` binary.
4 - If you use the `php-worker` or `laravel-horizon` container too, please follow the same steps above especially if you have processing that have been queued.
**PS** Don't forget to install the binary in the `php-fpm` container too by applying the same steps above to its container, otherwise you'll get an error when running the `audiowaveform` binary.
**PS** Don't forget to install the binary in the `php-fpm` container too by applying the same steps above to its container, otherwise the you'll get an error when running the `wkhtmltopdf` binary.
3 - Create supervisor configuration file (for ex., named `laravel-worker.conf`) for Laravel Queue Worker in `php-worker/supervisord.d/` by simply copy from `laravel-worker.conf.example`
When you start your docker container, Laradock will copy the `aliases.sh` file located in the `laradock/workspace` directory and add sourcing to the container `~/.bashrc` file.
YAML PHP extension allows you to easily parse and create YAML structured data. I like YAML because it's well readable for humans. See http://php.net/manual/en/ref.yaml.php and http://yaml.org/ for more info.
AST exposes the abstract syntax tree generated by PHP 7+. This extension is required by tools such as `Phan`, a static analyzer for PHP.
1 - Open the `.env` file
2 - Search for the `WORKSPACE_INSTALL_AST` argument under the Workspace Container
3 - Set it to `true`
4 - Re-build the container `docker-compose build workspace`
**Note** If you need a specific version of AST then search for the `WORKSPACE_AST_VERSION` argument under the Workspace Container and set it to the desired version and continue step 4.
The PHP Decimal extension adds support for correctly-rounded, arbitrary-precision decimal floating point arithmetic. Applications that rely on accurate numbers (ie. money, measurements, or mathematics) can use Decimal instead of float or string to represent numerical values.
For more information visit the [PHP Decimal website](https://php-decimal.io).
2 - Search for the `WORKSPACE_INSTALL_PHPDECIMAL` argument under the Workspace Container
2 - Search for the `PHP_FPM_INSTALL_PHPDECIMAL` argument under the PHP-FPM container
3 - Set it to `true`
4 - Re-build the container `docker-compose build workspace php-fpm`
A bash prompt that displays information about the current git repository. In particular the branch name, difference with remote branch, number of files staged, changed, etc.
1 - Open the `.env` file
2 - Search for the `WORKSPACE_INSTALL_GIT_PROMPT` argument under the Workspace Container
3 - Set it to `true`
4 - Re-build the container `docker-compose build workspace`
**Note** You can configure bash-git-prompt by editing the `workspace/gitprompt.sh` file and re-building the workspace container.
For configuration information, visit the [bash-git-prompt repository](https://github.com/magicmonty/bash-git-prompt).
[Zsh](https://en.wikipedia.org/wiki/Z_shell) is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.
[Oh My Zsh](https://ohmyz.sh/) is a delightful, open source, community-driven framework for managing your Zsh configuration.
[Laravel autocomplete plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/laravel) adds aliases and autocompletion for Laravel Artisan and Bob command-line interfaces.
1 - Open the `.env` file
2 - Search for the `SHELL_OH_MY_ZSH` argument under the Workspace Container
3 - Set it to `true`
4 - Re-build the container `docker-compose build workspace`
Docker on the Mac [is slow](https://github.com/docker/for-mac/issues/77), at the time of writing. Especially for larger projects, this can be a problem. The problem is [older than March 2016](https://forums.docker.com/t/file-access-in-mounted-volumes-extremely-slow-cpu-bound/8076) - as it's a such a long-running issue, we're including it in the docs here.
So since sharing code into Docker containers with osxfs have very poor performance compared to Linux. Likely there are some workarounds:
[Dinghy](https://github.com/codekitchen/dinghy) creates its own VM using docker-machine, it will not modify your existing docker-machine VMs.
Quick Setup giude, (we recommend you check their docs)
1) `brew tap codekitchen/dinghy`
2) `brew install dinghy`
3) `dinghy create --provider virtualbox` (must have virtualbox installed, but they support other providers if you prefer)
4) after the above command is done it will display some env variables, copy them to the bash profile or zsh or.. (this will instruct docker to use the server running inside the VM)
You can use the d4m-nfs solution in 2 ways, the first is by using the built-in Laradock integration, and the second is using the tool separately. Below is show case of both methods:
In simple terms, docker-sync creates a docker container with a copy of all the application files that can be accessed very quickly from the other containers.
On the other hand, docker-sync runs a process on the host machine that continuously tracks and updates files changes from the host to this intermediate container.
Out of the box, it comes pre-configured for OS X, but using it on Windows is very easy to set-up by modifying the `DOCKER_SYNC_STRATEGY` on the `.env`
Laradock comes with `sync.sh`, an optional bash script, that automates installing, running and stopping docker-sync. Note that to run the bash script you may need to change the permissions `chmod 755 sync.sh`
1) Configure your Laradock environment as you would normally do and test your application to make sure that your sites are running correctly.
2) Make sure to set `DOCKER_SYNC_STRATEGY` on the `.env`. Read the [syncing strategies](https://github.com/EugenMayer/docker-sync/wiki/8.-Strategies) for details.
Specify the services you want to run, as you would normally do with `docker-compose up`
```bash
./sync.sh up nginx mysql
```
Please note that the first time docker-sync runs, it will copy all the files to the intermediate container and that may take a very long time (15min+).
Opening bash on the workspace container (to run artisan for example):
```bash
./sync.sh bash
```
Manually triggering the synchronization of the files:
```bash
./sync.sh sync
```
Removing and cleaning up the files and the docker-sync container. Use only if you want to rebuild or remove docker-sync completely. The files on the host will be kept untouched.
- You may run laradock with or without docker-sync at any time using with the same `.env` and `docker-compose.yml`, because the configuration is overridden automatically when docker-sync is used.
- You may inspect the `sync.sh` script to learn each of the commands and even add custom ones.
- If a container cannot access the files on docker-sync, you may need to set a user on the Dockerfile of that container with an id of 1000 (this is the UID that nginx and php-fpm have configured on laradock). Alternatively, you may change the permissions to 777, but this is **not** recommended.
Visit the [docker-sync documentation](https://github.com/EugenMayer/docker-sync/wiki) for more details.
5) Create (or edit) the file `/etc/exports`, make sure it exists and is empty. (There may be collisions if you come from Vagrant or if you already executed the `d4m-nfs.sh` script before).
*Note: If you faced any errors, try restarting Docker, and make sure you have no spaces in the `d4m-nfs-mounts.txt` file, and your `/etc/exports` file is clear.*