diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..8359c58e --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at mahmoud@zalt.me. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..7d5865b0 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,3 @@ +### First off, thanks for taking the time to contribute! + +For the contribution guide [click here](http://laradock.io/contributing/). diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 4cb3eea4..eff16ef7 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -5,22 +5,19 @@ - System info disto/version: ### Issue: -##### What seems to be going wrong? - + _____ ### Expected behavior: -##### What should be happening instead? - + _____ ### Reproduce: -##### How might we be able to reproduce the error? - + _____ ### Relevant Code: ``` -// place code here +// place a code sample here ``` diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..9160f018 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ + + +##### I completed the 3 steps below: + +- [] I've read the [Contribution Guide](http://laradock.io/contributing). +- [] I've updated the **documentation**. (refer to [this](http://laradock.io/contributing/#update-the-documentation-site) for how to do so). +- [] I enjoyed my time contributing and making developer's life easier :) diff --git a/README-zh.md b/.github/README-zh.md similarity index 100% rename from README-zh.md rename to .github/README-zh.md diff --git a/.github/README.md b/.github/README.md new file mode 100644 index 00000000..7bc43ac1 --- /dev/null +++ b/.github/README.md @@ -0,0 +1,49 @@ +

+ Laradock Logo +

+ +

A Docker PHP development environment that facilitates running PHP Apps on Docker

+ +

+ Build status + GitHub stars + GitHub forks + GitHub issues + GitHub license + contributions welcome +

+ +

Use Docker First And Learn About It Later

+ +

+ forthebadge +

+ + +--- + +

+ + Laradock Docs + +

+ + +## Credits + +- [Mahmoud Zalt](https://github.com/Mahmoudz) @mahmoudz | [Twitter](https://twitter.com/Mahmoud_Zalt) | [Site](http://zalt.me) +- [Bo-Yi Wu](https://github.com/appleboy) @appleboy | [Twitter](https://twitter.com/appleboy) +- [Philippe Trépanier](https://github.com/philtrep) @philtrep +- [Mike Erickson](https://github.com/mikeerickson) @mikeerickson +- [Dwi Fahni Denni](https://github.com/zeroc0d3) @zeroc0d3 +- [Thor Erik](https://github.com/thorerik) @thorerik +- [Winfried van Loon](https://github.com/winfried-van-loon) @winfried-van-loon +- [TJ Miller](https://github.com/sixlive) @sixlive +- [Yu-Lung Shao (Allen)](https://github.com/bestlong) @bestlong +- [Milan Urukalo](https://github.com/urukalo) @urukalo +- [Vince Chu](https://github.com/vwchu) @vwchu +- Join Us. + +## License + +[MIT License](https://github.com/laradock/laradock/blob/master/LICENSE) diff --git a/.gitignore b/.gitignore index a6b304c9..702790af 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /logs /data .env -/.project \ No newline at end of file +/.project +.docker-sync \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 03e4e584..f54fc735 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,8 +41,11 @@ env: # Installing a newer Docker version before_install: + - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - sudo apt-get update - - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-engine + - sudo apt-get -y install docker-ce + - docker version script: ./travis-build.sh diff --git a/DOCUMENTATION/content/documentation/index.md b/DOCUMENTATION/content/documentation/index.md index e447225b..f3a77807 100644 --- a/DOCUMENTATION/content/documentation/index.md +++ b/DOCUMENTATION/content/documentation/index.md @@ -5,6 +5,8 @@ weight: 3 --- + + ## List current running Containers ```bash @@ -153,28 +155,8 @@ You might use the `--no-cache` option if you want full rebuilding (`docker-compo -
- - -## Docker-Sync - -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. - -The problem originates in bind-mount performance on MacOS. Docker for Mac uses osxfs by default. This is not without reason, it has [a lot of advantages](https://docs.docker.com/docker-for-mac/osxfs/). - -Solutions to resolve this issue are easily installed however, we're hoping it'll be fixed by Docker themselves over time. They are currently [adding "cached and delegated" options](https://github.com/docker/for-mac/issues/77#issuecomment-283996750), which is partly available for Docker Edge. - -Options are [to switch over to NFS](https://github.com/IFSight/d4m-nfs) which is the simplest. The fastest option is [Docker-Sync "native"](https://github.com/EugenMayer/docker-sync) which is still quite easy to install. - -Clone [this repo](https://github.com/EugenMayer/docker-sync-boilerplate) to your machine, copy `default/docker-sync.yml` to your Laradock directory and run `docker-sync-stack start`. Be sure to use `docker-sync-stack clean` to stop and `docker-compose build` to rebuild. More information can be found [in the Docker-sync docs](https://github.com/EugenMayer/docker-sync). - - - - -
- ## Add more Software (Docker Images) 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/). @@ -192,14 +174,17 @@ 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: ```bash -docker logs {container-name} +docker-compose logs {container-name} +``` + +```bash +docker-compose logs -f {container-name} ``` More [options](https://docs.docker.com/compose/reference/logs/) -```bash -docker logs -f {container-name} -``` + + @@ -247,7 +232,7 @@ By default **PHP-FPM 7.0** is running. php-fpm: build: context: ./php-fpm - dockerfile: Dockerfile-70 + dockerfile: Dockerfile-56 ... ``` @@ -330,9 +315,7 @@ It should be like this: ... ``` -2 - Re-build the containers `docker-compose build workspace php-fpm` - -3 - Open `laradock/workspace/xdebug.ini` and/or `laradock/php-fpm/xdebug.ini` and enable at least the following configurations: +2 - Open `laradock/workspace/xdebug.ini` and `laradock/php-fpm/xdebug.ini` and enable at least the following configurations: ``` xdebug.remote_autostart=1 @@ -340,11 +323,25 @@ xdebug.remote_enable=1 xdebug.remote_connect_back=1 ``` -For information on how to configure xDebug with your IDE and work it out, check this [Repository](https://github.com/LarryEitel/laravel-laradock-phpstorm). +3 - Re-build the containers `docker-compose build workspace php-fpm` + +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. + +## Setup remote debugging for PhpStorm on Linux + - Make sure you have followed the steps above in the [Install Xdebug section](http://laradock.io/documentation/#install-xdebug). + - Make sure Xdebug accepts connections and listens on port 9000. (Should be default configuration). + +![Debug Configuration](/images/photos/PHPStorm/linux/configuration/debugConfiguration.png "Debug Configuration"). + + - Create a server with name `laradock` (matches **PHP_IDE_CONFIG** key in environment file) and make sure to map project root path with server correctly. + +![Server Configuration](/images/photos/PHPStorm/linux/configuration/serverConfiguration.png "Server Configuration"). + + - Start listening for debug connections, place a breakpoint and you are good to go !
@@ -734,7 +731,7 @@ docker-compose up -d mariadb phpmyadmin 1 - Run the Adminer Container (`adminer`) with the `docker-compose up` command. Example: ```bash -docker-compose up -d adminer +docker-compose up -d adminer ``` 2 - Open your browser and visit the localhost on port **8080**: `http://localhost:8080` @@ -946,9 +943,18 @@ To install CodeIgniter 3 on Laradock all you have to do is the following simple 3 - Re-build your PHP-FPM Container `docker-compose build php-fpm`. + +## Install Symfony +1 - Open the `.env` file and set `WORKSPACE_INSTALL_SYMFONY` to `true`. +2 - Run `docker-compose build workspace`, after the step above. +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. + +4 - Run `docker-compose restart` if the container was already running, before the step above. + +5 - Visit `symfony.dev`
@@ -1023,6 +1029,26 @@ To change the default forwarded port for ssh: +
+ +## Change the (MySQL) Version +By default **MySQL 8.0** is running. + +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. + + + + + +
## MySQL access from host @@ -1057,6 +1083,19 @@ The default username and password for the root MySQL user are `root` and `root ` +
+ +## Create Multiple Databases (MySQL) + +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' ; +GRANT ALL ON `your_db_1`.* TO 'mysql_user'@'%' ; +``` + + +
@@ -1377,7 +1416,11 @@ Moving from Docker Toolbox (VirtualBox) to Docker Native (for Mac/Windows). Requ ## Improve speed on MacOS -Sharing code into Docker containers with osxfs have very poor performance compared to Linux. Likely there are some workarounds: +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: + + ### Workaround A: using dinghy @@ -1397,9 +1440,99 @@ Quick Setup giude, (we recommend you check their docs) - +
+ ### Workaround B: using d4m-nfs +You can use the d4m-nfs solution in 2 ways, one is using the Laradock built it integration, and the other is using the tool separatly. Below is show case of both methods: + + +#### B.1: using the built in d4m-nfs integration + +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` + +##### Usage + +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. +``` +# osx: 'native_osx' (default) +# windows: 'unison' +# linux: docker-sync not required + +DOCKER_SYNC_STRATEGY=native_osx +``` + +2) Install the docker-sync gem on the host-machine: +```bash +./sync.sh install +``` +3) Start docker-sync and the Laradock environment. +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+). +4) To stop the environment and docker-sync do: +```bash +./sync.sh down +``` + +##### Setting up Aliases (optional) + +You may create bash profile aliases to avoid having to remember and type these commands for everyday development. +Add the following lines to your `~/.bash_profile`: + +```bash +alias devup="cd /PATH_TO_LARADOCK/laradock; ./sync.sh up nginx mysql" #add your services +alias devbash="cd /PATH_TO_LARADOCK/laradock; ./sync.sh bash" +alias devdown="cd /PATH_TO_LARADOCK/laradock; ./sync.sh down" +``` + +Now from any location on your machine, you can simply run `devup`, `devbash` and `devdown`. + + +##### Additional Commands + +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. +```bash +./sync.sh clean +``` + + +##### Additional Notes + +- 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. + + + + + + + + +
+ +#### B.2: using the d4m-nfs tool + [D4m-nfs](https://github.com/IFSight/d4m-nfs) automatically mount NFS volume instead of osxfs one. 1) Update the Docker [File Sharing] preferences: @@ -1439,17 +1572,10 @@ docker-compose up ... -### Other good workarounds: - -- [docker-sync](https://github.com/EugenMayer/docker-sync) -- Add more here.. -More details about this issue [here](https://github.com/docker/for-mac/issues/77). - - diff --git a/DOCUMENTATION/content/getting-started/index.md b/DOCUMENTATION/content/getting-started/index.md index 0aba2e0a..cbbdfb68 100644 --- a/DOCUMENTATION/content/getting-started/index.md +++ b/DOCUMENTATION/content/getting-started/index.md @@ -112,9 +112,9 @@ Your folder structure should look like this: 2 - Go to `nginx/sites` and create config files to point to different project directory when visiting different domains. -Laradock by default includes `project-1.conf` and `project-2.conf` as working samples. +Laradock by default includes `app.conf.example`, `laravel.conf.example` and `symfony.conf.example` as working samples. -3 - change the default names `project-n`: +3 - change the default names `*.conf`: You can rename the config files, project folders and domains as you like, just make sure the `root` in the config files, is pointing to the correct project folder name. @@ -123,6 +123,7 @@ You can rename the config files, project folders and domains as you like, just m ``` 127.0.0.1 project-1.dev 127.0.0.1 project-2.dev +... ``` > **Now jump to the [Usage](#Usage) section.** diff --git a/DOCUMENTATION/content/guides/index.md b/DOCUMENTATION/content/guides/index.md index ffc0c3e6..d166604c 100644 --- a/DOCUMENTATION/content/guides/index.md +++ b/DOCUMENTATION/content/guides/index.md @@ -8,6 +8,7 @@ weight: 4 * [Production Setup on Digital Ocean](#Digital-Ocean) * [PHPStorm XDebug Setup](#PHPStorm-Debugging) +* [Running Laravel Dusk Test](#Laravel-Dusk) @@ -326,6 +327,7 @@ Set the following variables: - `laradock/php-fpm/xdebug.ini` Set the following variables: + ``` xdebug.remote_autostart=1 xdebug.remote_enable=1 @@ -336,34 +338,39 @@ xdebug.cli_color=1 ### Need to clean house first? + Make sure you are starting with a clean state. For example, do you have other Laradock containers and images? Here are a few things I use to clean things up. - Delete all containers using `grep laradock_` on the names, see: [Remove all containers based on docker image name](https://linuxconfig.org/remove-all-containners-based-on-docker-image-name). + `docker ps -a | awk '{ print $1,$2 }' | grep laradock_ | awk '{print $1}' | xargs -I {} docker rm {}` - Delete all images containing `laradock`. + `docker images | awk '{print $1,$2,$3}' | grep laradock_ | awk '{print $3}' | xargs -I {} docker rmi {}` **Note:** This will only delete images that were built with `Laradock`, **NOT** `laradock/*` which are pulled down by `Laradock` such as `laradock/workspace`, etc. **Note:** Some may fail with: `Error response from daemon: conflict: unable to delete 3f38eaed93df (cannot be forced) - image has dependent child images` - I added this to my `.bashrc` to remove orphaned images. - ``` - dclean() { - processes=`docker ps -q -f status=exited` - if [ -n "$processes" ]; thend - docker rm $processes - fi - images=`docker images -q -f dangling=true` - if [ -n "$images" ]; then - docker rmi $images - fi - } - ``` +``` +dclean() { + processes=`docker ps -q -f status=exited` + if [ -n "$processes" ]; thend + docker rm $processes + fi + + images=`docker images -q -f dangling=true` + if [ -n "$images" ]; then + docker rmi $images + fi +} +``` - If you frequently switch configurations for Laradock, you may find that adding the following and added to your `.bashrc` or equivalent useful: + ``` # remove laravel* containers # remove laravel_* images @@ -406,14 +413,14 @@ laradock_php-fpm_1 php-fpm Up 9000/tcp laradock_volumes_data_1 true Exit 0 laradock_volumes_source_1 true Exit 0 laradock_workspace_1 /sbin/my_init Up 0.0.0.0:2222->22/tcp - - ``` ## Enable xDebug on php-fpm + In a host terminal sitting in the laradock folder, run: `.php-fpm/xdebug status` You should see something like the following: + ``` xDebug status laradock_php-fpm_1 @@ -422,6 +429,7 @@ Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans ``` + Other commands include `.php-fpm/xdebug start | stop`. If you have enabled `xdebug=true` in `docker-compose.yml/php-fpm`, `xdebug` will already be running when @@ -430,6 +438,7 @@ If you have enabled `xdebug=true` in `docker-compose.yml/php-fpm`, `xdebug` will ## PHPStorm Settings + - Here are some settings that are known to work: - `Settings/BuildDeploymentConnection` - ![Settings/BuildDeploymentConnection](/images/photos/PHPStorm/Settings/BuildDeploymentConnection.png) @@ -547,4 +556,149 @@ Assuming that you are in laradock folder, type: - ![ConnectionSSHAuth](/images/photos/KiTTY/ConnectionSSHAuth.png) - ![TerminalShell](/images/photos/KiTTY/TerminalShell.png) +
+
+
+
+
+ +# Running Laravel Dusk Tests + +- [Intro](#dusk-intro) +- [DNS Setup](#dns-setup) +- [Docker Compose Setup](#docker-compose) +- [Laravel Dusk Setup](#laravel-dusk-setup) +- [Running Laravel Dusk Tests](#running-tests) + + +## 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, +it's only been tested on macOS. Feel free to create pull requests to update the guide +for Windows-specific instructions. + +This guide assumes you know how to use a DNS forwarder such as `dnsmasq` or are comfortable +with editing the `/etc/hosts` file for one-off DNS changes. + + +## DNS Setup +According to RFC-2606, only four TLDs are reserved for local testing[^1]: + +- `.test` +- `.example` +- `.invalid` +- `.localhost` + +A common TLD used for local development is `.dev`, but newer versions of Google +Chrome (such as the one bundled with the Selenium Docker image), will fail to +resolve that DNS as there will appear to be a name collision. + +The recommended extension is `.test` for your Laravel web apps because you're +running tests. Using a DNS forwarder such as `dnsmasq` or by editing the `/etc/hosts` +file, configure the host to point to `localhost`. + +For example, in your `/etc/hosts` file: +``` +## +# Host Database +# +# localhost is used to configure the loopback interface +# when the system is booting. Do not change this entry. +## +127.0.0.1 localhost +255.255.255.255 broadcasthost +::1 localhost +127.0.0.1 myapp.test +``` + +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 +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: + +```yaml +... +selenium: + ... + depends_on: + - nginx + links: + - nginx: +``` + +This allows network communication between the Nginx and Selenium containers +and it also ensures that when starting the Selenium container, the Nginx +container starts up first unless it's already running. This allows +the Selenium container to make requests to the Nginx container, which is +necessary for running Dusk tests. These changes also link the `nginx` environment +variable to the domain you wired up in your hosts file. + + +## 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 +installation of Laravel Dusk. The change you have to make deals with the URL the +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 +``` +... +USE_SELENIUM=true +``` + +### DuskTestCase.php +```php +abstract class DuskTestCase extends BaseTestCase +{ +... + protected function driver() + { + if (env('USE_SELENIUM', 'false') == 'true') { + return RemoteWebDriver::create( + 'http://selenium:4444/wd/hub', DesiredCapabilities::chrome() + ); + } else { + return RemoteWebDriver::create( + 'http://localhost:9515', DesiredCapabilities::chrome() + ); + } + } +} +``` + + +## 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: +```docker-compose exec --user=laradock workspace bash``` + +Once inside, you can change directory to your application and run: + +```php artisan dusk``` + +One way to make this easier from your project is to create a helper script. Here's one such example: +```bash +#!/usr/bin/env sh + +LARADOCK_HOME="path/to/laradock" + +pushd ${LARADOCK_HOME} + +docker-compose exec --user=laradock workspace bash -c "cd my-project && php artisan dusk && exit" +``` + +This invokes the Dusk command from inside the workspace container but when the script completes +execution, it returns your session to your project directory. + +[^1]: [Don't Use .dev for Development](https://iyware.com/dont-use-dev-for-development/) diff --git a/DOCUMENTATION/content/introduction/index.md b/DOCUMENTATION/content/introduction/index.md index 120a3e51..115a79c6 100644 --- a/DOCUMENTATION/content/introduction/index.md +++ b/DOCUMENTATION/content/introduction/index.md @@ -83,17 +83,21 @@ In adhering to the separation of concerns principle as promoted by Docker, Larad You can turn On/Off as many instances of as any container without worrying about the configurations, everything works like a charm. - **Database Engines:** -MySQL - MariaDB - Percona - MongoDB - Neo4j - RethinkDB - MSSQL - PostgreSQL - Postgres Postgis. +MySQL - MariaDB - Percona - MongoDB - Neo4j - RethinkDB - MSSQL - PostgreSQL - Postgres-PostGIS. +- **Database Management:** +PhpMyAdmin - Adminer - PgAdmin - **Cache Engines:** Redis - Memcached - Aerospike - **PHP Servers:** NGINX - Apache2 - Caddy - **PHP Compilers:** PHP FPM - HHVM -- **Message Queuing:** -Beanstalkd - Beanstalkd Console - RabbitMQ - RabbitMQ Console - PHP Worker -- **Tools:** -HAProxy - Jenkins - ElasticSearch - Selenium - Certbot - Mailhog - Minio - Varnish - PhpMyAdmin - Adminer - PgAdmin - MailHog - [Blackfire](https://blackfire.io)... +- **Message Queueing:** +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... 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. @@ -148,7 +152,7 @@ Most importantly Docker can run on Development and on Production (same environme What's better than a **Demo Video**: -- Laradock v5.* (soon or never) +- Laradock v5.* (should be next!) - Laradock [v4.*](https://www.youtube.com/watch?v=TQii1jDa96Y) - Laradock [v2.*](https://www.youtube.com/watch?v=-DamFMczwDA) - Laradock [v0.3](https://www.youtube.com/watch?v=jGkyO6Is_aI) diff --git a/DOCUMENTATION/themes/hugo-material-docs/static/images/photos/PHPStorm/linux/configuration/debugConfiguration.png b/DOCUMENTATION/themes/hugo-material-docs/static/images/photos/PHPStorm/linux/configuration/debugConfiguration.png new file mode 100644 index 00000000..e69d5395 Binary files /dev/null and b/DOCUMENTATION/themes/hugo-material-docs/static/images/photos/PHPStorm/linux/configuration/debugConfiguration.png differ diff --git a/DOCUMENTATION/themes/hugo-material-docs/static/images/photos/PHPStorm/linux/configuration/serverConfiguration.png b/DOCUMENTATION/themes/hugo-material-docs/static/images/photos/PHPStorm/linux/configuration/serverConfiguration.png new file mode 100644 index 00000000..30b7cd07 Binary files /dev/null and b/DOCUMENTATION/themes/hugo-material-docs/static/images/photos/PHPStorm/linux/configuration/serverConfiguration.png differ diff --git a/README.md b/README.md deleted file mode 100644 index 269465c6..00000000 --- a/README.md +++ /dev/null @@ -1,32 +0,0 @@ -![](https://s19.postimg.org/jblfytw9f/laradock-logo.jpg) - -[![Build Status](https://travis-ci.org/laradock/laradock.svg?branch=master)](https://travis-ci.org/laradock/laradock) [![GitHub issues](https://img.shields.io/github/issues/laradock/laradock.svg)](https://github.com/laradock/laradock/issues) [![GitHub forks](https://img.shields.io/github/forks/laradock/laradock.svg)](https://github.com/laradock/laradock/network) [![GitHub stars](https://img.shields.io/github/stars/laradock/laradock.svg)](https://github.com/laradock/laradock/stargazers) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/laradock/laradock/master/LICENSE) - -> Use Docker first and learn about it later. - -A Docker PHP development environment that facilitates running **PHP** Apps on **Docker**. - -[![forthebadge](http://forthebadge.com/images/badges/built-by-developers.svg)](http://zalt.me) - -## Documentation - -[**Full Documentation Here**](http://laradock.io) - -## Credits - -**Maintainers:** - -- [Mahmoud Zalt](https://github.com/Mahmoudz) @mahmoudz | [Twitter](https://twitter.com/Mahmoud_Zalt) | [Site](http://zalt.me) -- [Bo-Yi Wu](https://github.com/appleboy) @appleboy | [Twitter](https://twitter.com/appleboy) -- [Philippe Trépanier](https://github.com/philtrep) @philtrep -- [Mike Erickson](https://github.com/mikeerickson) @mikeerickson -- [Dwi Fahni Denni](https://github.com/zeroc0d3) @zeroc0d3 -- [Thor Erik](https://github.com/thorerik) @thorerik -- [Winfried van Loon](https://github.com/winfried-van-loon) @winfried-van-loon -- [TJ Miller](https://github.com/sixlive) @sixlive -- [Yu-Lung Shao (Allen)](https://github.com/bestlong) @bestlong -- Join Us. - -## License - -[MIT License](https://github.com/laradock/laradock/blob/master/LICENSE) (MIT) diff --git a/adminer/Dockerfile b/adminer/Dockerfile index 6117454f..818c8e13 100644 --- a/adminer/Dockerfile +++ b/adminer/Dockerfile @@ -8,5 +8,22 @@ MAINTAINER Patrick Artounian # Add volume for sessions to allow session persistence VOLUME /sessions +##################################### +# SQL SERVER: +##################################### +USER root +ARG INSTALL_MSSQL=false +ENV INSTALL_MSSQL ${INSTALL_MSSQL} +RUN if [ ${INSTALL_MSSQL} = true ]; then \ + set -xe \ + && apk --update add --no-cache --virtual .phpize-deps $PHPIZE_DEPS unixodbc unixodbc-dev \ + && pecl channel-update pecl.php.net \ + && pecl install pdo_sqlsrv-4.1.8preview sqlsrv-4.1.8preview \ + && echo "extension=sqlsrv.so" > /usr/local/etc/php/conf.d/20-sqlsrv.ini \ + && echo "extension=pdo_sqlsrv.so" > /usr/local/etc/php/conf.d/20-pdo_sqlsrv.ini \ +;fi + +USER adminer + # We expose Adminer on port 8080 (Adminer's default) EXPOSE 8080 diff --git a/apache2/Dockerfile b/apache2/Dockerfile index 9d4d9a9a..bc152dd3 100644 --- a/apache2/Dockerfile +++ b/apache2/Dockerfile @@ -2,15 +2,16 @@ FROM webdevops/apache:ubuntu-16.04 MAINTAINER Eric Pfeiffer -ARG PHP_SOCKET=php-fpm:9000 +ARG PHP_UPSTREAM_CONTAINER=php-fpm +ARG PHP_UPSTREAM_PORT=9000 -ENV WEB_PHP_SOCKET=$PHP_SOCKET +ENV WEB_PHP_SOCKET=${PHP_UPSTREAM_CONTAINER}:${PHP_UPSTREAM_PORT} -ENV WEB_DOCUMENT_ROOT=/var/www/public/ +ENV WEB_DOCUMENT_ROOT=/var/www/ EXPOSE 80 443 -WORKDIR /var/www/public/ +WORKDIR /var/www/ COPY vhost.conf /etc/apache2/sites-enabled/vhost.conf diff --git a/apache2/sites/default.apache.conf b/apache2/sites/default.apache.conf index 5cedafb6..18ee6de5 100644 --- a/apache2/sites/default.apache.conf +++ b/apache2/sites/default.apache.conf @@ -1,9 +1,9 @@ ServerName laradock.dev - DocumentRoot /var/www/public/ + DocumentRoot /var/www/ Options Indexes FollowSymLinks - + AllowOverride All Allow from all diff --git a/caddy/Caddyfile b/caddy/Caddyfile index 269b62a1..288d9d3b 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -1,28 +1,30 @@ # Docs: https://caddyserver.com/docs/caddyfile -0.0.0.0:80 -root /var/www/public -fastcgi / php-fpm:9000 php { - index index.php +0.0.0.0:80 { + root /var/www/public + fastcgi / php-fpm:9000 php { + index index.php + } + + # To handle .html extensions with laravel change ext to + # ext / .html + + rewrite { + to {path} {path}/ /index.php?{query} + } + gzip + browse + log /var/log/caddy/access.log + errors /var/log/caddy/error.log + # Uncomment to enable TLS (HTTPS) + # Change the first list to listen on port 443 when enabling TLS + #tls self_signed + + # To use Lets encrpt tls with a DNS provider uncomment these + # lines and change the provider as required + #tls { + # dns cloudflare + #} } - -# To handle .html extensions with laravel change ext to -# ext / .html - -rewrite { - r .* - ext / - to /index.php?{query} +laradock.demo { + root /var/www/public } -gzip -browse -log /var/log/caddy/access.log -errors /var/log/caddy/error.log -# Uncomment to enable TLS (HTTPS) -# Change the first list to listen on port 443 when enabling TLS -#tls self_signed - -# To use Lets encrpt tls with a DNS provider uncomment these -# lines and change the provider as required -#tls { -# dns cloudflare -#} diff --git a/caddy/Dockerfile b/caddy/Dockerfile index b10a9f52..d88fe390 100644 --- a/caddy/Dockerfile +++ b/caddy/Dockerfile @@ -1,18 +1,19 @@ -FROM alpine:3.4 +FROM alpine:3.5 MAINTAINER Eric Pfeiffer -ENV caddy_version=0.10.0 +ENV caddy_version=0.10.5 +ARG plugins=http.git LABEL caddy_version="$caddy_version" architecture="amd64" RUN apk update \ && apk upgrade \ - && apk add tar curl git + && apk add --no-cache openssh-client git tar curl 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=http.cgi,http.cors,http.expires,http.filemanager,http.git,http.ipfilter,http.realip,tls.dns.cloudflare,tls.dns.digitalocean,tls.dns.dnspod,tls.dns.dyn,tls.dns.googlecloud,tls.dns.linode,tls.dns.namecheap,tls.dns.ovh,tls.dns.route53,tls.dns.vultr" \ + "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 diff --git a/docker-compose.sync.yml b/docker-compose.sync.yml new file mode 100644 index 00000000..20bb016a --- /dev/null +++ b/docker-compose.sync.yml @@ -0,0 +1,17 @@ +version: '2' + +services: + +### Applications Code Container ############################# + + applications: + image: tianon/true + volumes: + - applications-sync:/var/www:nocopy # nocopy is required + +### Volumes Setup ############################################# + +volumes: + applications-sync: + external: + name: "applications-docker-sync" diff --git a/docker-compose.yml b/docker-compose.yml index c79ba6aa..2173df74 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,14 +23,19 @@ services: - INSTALL_NODE=${WORKSPACE_INSTALL_NODE} - INSTALL_YARN=${WORKSPACE_INSTALL_YARN} - INSTALL_DRUSH=${WORKSPACE_INSTALL_DRUSH} + - INSTALL_DRUPAL_CONSOLE=${WORKSPACE_INSTALL_DRUPAL_CONSOLE} - INSTALL_AEROSPIKE=${WORKSPACE_INSTALL_AEROSPIKE} - INSTALL_V8JS=${WORKSPACE_INSTALL_V8JS} - COMPOSER_GLOBAL_INSTALL=${WORKSPACE_COMPOSER_GLOBAL_INSTALL} - INSTALL_WORKSPACE_SSH=${WORKSPACE_INSTALL_WORKSPACE_SSH} - INSTALL_LARAVEL_ENVOY=${WORKSPACE_INSTALL_LARAVEL_ENVOY} + - INSTALL_LARAVEL_INSTALLER=${WORKSPACE_INSTALL_LARAVEL_INSTALLER} - INSTALL_DEPLOYER=${WORKSPACE_INSTALL_DEPLOYER} - INSTALL_LINUXBREW=${WORKSPACE_INSTALL_LINUXBREW} - INSTALL_MC=${WORKSPACE_INSTALL_MC} + - INSTALL_SYMFONY=${WORKSPACE_INSTALL_SYMFONY} + - INSTALL_PYTHON=${WORKSPACE_INSTALL_PYTHON} + - INSTALL_IMAGE_OPTIMIZERS=${WORKSPACE_INSTALL_IMAGE_OPTIMIZERS} - PUID=${WORKSPACE_PUID} - PGID=${WORKSPACE_PGID} - NODE_VERSION=${WORKSPACE_NODE_VERSION} @@ -74,6 +79,7 @@ services: - INSTALL_GHOSTSCRIPT=${PHP_FPM_INSTALL_GHOSTSCRIPT} - INSTALL_LDAP=${PHP_FPM_INSTALL_LDAP} - INSTALL_SWOOLE=${PHP_FPM_INSTALL_SWOOLE} + - INSTALL_IMAGE_OPTIMIZERS=${PHP_FPM_INSTALL_IMAGE_OPTIMIZERS} dockerfile: "Dockerfile-${PHP_VERSION}" volumes_from: - applications @@ -95,6 +101,7 @@ services: php-worker: build: context: ./php-worker + dockerfile: "Dockerfile-${PHP_VERSION}" volumes_from: - applications depends_on: @@ -104,13 +111,14 @@ services: networks: - backend -### Nginx Server Container ################################## +### NGINX Server Container ################################## nginx: build: context: ./nginx args: - - PHP_UPSTREAM=php-fpm + - PHP_UPSTREAM_CONTAINER=${NGINX_PHP_UPSTREAM_CONTAINER} + - PHP_UPSTREAM_PORT=${NGINX_PHP_UPSTREAM_PORT} volumes_from: - applications volumes: @@ -143,12 +151,13 @@ services: build: context: ./apache2 args: - - PHP_SOCKET=${PHP_SOCKET} + - PHP_UPSTREAM_CONTAINER=${APACHE_PHP_UPSTREAM_CONTAINER} + - PHP_UPSTREAM_PORT=${APACHE_PHP_UPSTREAM_PORT} volumes_from: - applications volumes: - ${APACHE_HOST_LOG_PATH}:/var/log/apache2 - - ./apache2/sites:/etc/apache2/sites-available + - ${APACHE_SITES_PATH}:/etc/apache2/sites-available ports: - "${APACHE_HOST_HTTP_PORT}:80" - "${APACHE_HOST_HTTPS_PORT}:443" @@ -191,16 +200,20 @@ services: mysql: build: context: ./mysql + args: + - MYSQL_VERSION=${MYSQL_VERSION} environment: - MYSQL_DATABASE=${MYSQL_DATABASE} - MYSQL_USER=${MYSQL_USER} - MYSQL_PASSWORD=${MYSQL_PASSWORD} - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} + - TZ=${WORKSPACE_TIMEZONE} volumes: - ${DATA_SAVE_PATH}/mysql:/var/lib/mysql - - ./mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d + - ${MYSQL_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d ports: - "${MYSQL_PORT}:3306" + user: "1000:50" networks: - backend @@ -216,7 +229,7 @@ services: - MYSQL_ROOT_PASSWORD=${PERCONA_ROOT_PASSWORD} volumes: - ${DATA_SAVE_PATH}/percona:/var/lib/mysql - - ./percona/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d + - ${PERCONA_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d ports: - "${PERCONA_PORT}:3306" networks: @@ -244,7 +257,7 @@ services: build: ./mariadb volumes: - ${DATA_SAVE_PATH}/mariadb:/var/lib/mysql - - ./mariadb/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d + - ${MARIADB_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d ports: - "${MARIADB_PORT}:3306" environment: @@ -328,7 +341,7 @@ services: volumes: - ${DATA_SAVE_PATH}/redis:/data ports: - - "6379:6379" + - "${REDIS_PORT}:6379" networks: - backend @@ -440,7 +453,10 @@ services: ### Adminer Container #################################### adminer: - build: ./adminer + build: + context: ./adminer + args: + - INSTALL_MSSQL=${ADM_INSTALL_MSSQL} ports: - "${ADM_PORT}:8080" depends_on: @@ -455,12 +471,15 @@ services: build: ./pgadmin ports: - "5050:5050" + volumes: + - ${DATA_SAVE_PATH}/pgadmin-backup:/var/lib/pgadmin4/data/storage/pgadmin4 depends_on: - postgres networks: - frontend - backend + ### ElasticSearch Container ################################# elasticsearch: @@ -468,6 +487,15 @@ services: volumes: - elasticsearch-data:/usr/share/elasticsearch/data - elasticsearch-plugins:/usr/share/elasticsearch/plugins + environment: + - cluster.name=laradock-cluster + - bootstrap.memory_lock=true + - "ES_JAVA_OPTS=-Xms256m -Xmx256m" + ulimits: + memlock: + soft: -1 + hard: -1 + mem_limit: 512m ports: - "${ELASTICSEARCH_HOST_HTTP_PORT}:9200" - "${ELASTICSEARCH_HOST_TRANSPORT_PORT}:9300" @@ -477,6 +505,19 @@ services: - frontend - backend + +### Kibana Container ####################################### + + kibana: + build: ./kibana + ports: + - "${KIBANA_HTTP_PORT}:5601" + depends_on: + - elasticsearch + networks: + - frontend + - backend + ### Certbot Container ################################## certbot: @@ -500,6 +541,7 @@ services: - "8025:8025" networks: - frontend + - backend ### Selenium Container ######################################## @@ -563,6 +605,7 @@ services: - proxy2 ### Jenkins ################################################### + jenkins: build: ./jenkins environment: @@ -578,6 +621,19 @@ services: - frontend - backend +### Laravel Echo Server ####################################### + laravel-echo-server: + build: + context: ./laravel-echo-server + volumes: + - ./laravel-echo-server/laravel-echo-server.json:/app/laravel-echo-server.json:ro + ports: + - "${LARAVEL_ECHO_SERVER_PORT}:6001" + links: + - redis + networks: + - frontend + - backend ### Networks Setup ############################################ diff --git a/docker-sync.yml b/docker-sync.yml new file mode 100644 index 00000000..bb70a26e --- /dev/null +++ b/docker-sync.yml @@ -0,0 +1,13 @@ +version: "2" + +options: + verbose: true +syncs: + applications-docker-sync: # name of the intermediary sync volume + compose-dev-file-path: 'docker-compose.sync.yml' # docker-compose override file + + src: '${APPLICATION}' # host source directory + sync_userid: 1000 # giving permissions to www-data user (as defined in nginx and php-fpm Dockerfiles) + sync_strategy: '${DOCKER_SYNC_STRATEGY}' # for osx use 'native_osx', for windows use 'unison' + + sync_excludes: ['laradock', 'ignored_folder_example'] # ignored directories diff --git a/elasticsearch/Dockerfile b/elasticsearch/Dockerfile index 363932e4..914761ee 100644 --- a/elasticsearch/Dockerfile +++ b/elasticsearch/Dockerfile @@ -1,5 +1,3 @@ -FROM elasticsearch:latest - -MAINTAINER Bo-Yi Wu +FROM docker.elastic.co/elasticsearch/elasticsearch:5.4.1 EXPOSE 9200 9300 diff --git a/env-example b/env-example index 7397b6d0..15beb1a2 100644 --- a/env-example +++ b/env-example @@ -10,7 +10,7 @@ APPLICATION=../ ### Data Path: # For all storage systems. -DATA_SAVE_PATH=/tmp +DATA_SAVE_PATH=~/.laradock/data ### PHP version # Applies to the Workspace and PHP-FPM containers (Does not apply to HHVM) @@ -36,14 +36,19 @@ WORKSPACE_INSTALL_MSSQL=false WORKSPACE_INSTALL_NODE=false WORKSPACE_INSTALL_YARN=false WORKSPACE_INSTALL_DRUSH=false +WORKSPACE_INSTALL_DRUPAL_CONSOLE=false WORKSPACE_INSTALL_AEROSPIKE=false WORKSPACE_INSTALL_V8JS=false WORKSPACE_COMPOSER_GLOBAL_INSTALL=false WORKSPACE_INSTALL_WORKSPACE_SSH=false WORKSPACE_INSTALL_LARAVEL_ENVOY=false +WORKSPACE_INSTALL_LARAVEL_INSTALLER=false WORKSPACE_INSTALL_DEPLOYER=false WORKSPACE_INSTALL_LINUXBREW=false WORKSPACE_INSTALL_MC=false +WORKSPACE_INSTALL_SYMFONY=false +WORKSPACE_INSTALL_PYTHON=false +WORKSPACE_INSTALL_IMAGE_OPTIMIZERS=false WORKSPACE_PUID=1000 WORKSPACE_PGID=1000 WORKSPACE_NODE_VERSION=stable @@ -70,6 +75,7 @@ PHP_FPM_INSTALL_INTL=false PHP_FPM_INSTALL_GHOSTSCRIPT=false PHP_FPM_INSTALL_LDAP=false PHP_FPM_INSTALL_SWOOLE=false +PHP_FPM_INSTALL_IMAGE_OPTIMIZERS=false ### NGINX ############################################################################################################## @@ -77,22 +83,31 @@ NGINX_HOST_HTTP_PORT=80 NGINX_HOST_HTTPS_PORT=443 NGINX_HOST_LOG_PATH=./logs/nginx/ NGINX_SITES_PATH=./nginx/sites/ +NGINX_PHP_UPSTREAM_CONTAINER=php-fpm +NGINX_PHP_UPSTREAM_PORT=9000 ### APACHE ############################################################################################################# APACHE_HOST_HTTP_PORT=80 APACHE_HOST_HTTPS_PORT=443 -APACHE2_PHP_SOCKET=php-fpm:9000 APACHE_HOST_LOG_PATH=./logs/apache2 -PHP_SOCKET=php-fpm:9000 +APACHE_SITES_PATH=./apache2/sites +APACHE_PHP_UPSTREAM_CONTAINER=php-fpm +APACHE_PHP_UPSTREAM_PORT=9000 ### MYSQL ############################################################################################################## +MYSQL_VERSION=8.0 MYSQL_DATABASE=default MYSQL_USER=default MYSQL_PASSWORD=secret MYSQL_PORT=3306 MYSQL_ROOT_PASSWORD=root +MYSQL_ENTRYPOINT_INITDB=./mysql/docker-entrypoint-initdb.d + +### REDIS ############################################################################################################## + +REDIS_PORT=6379 ### Percona ############################################################################################################ @@ -101,6 +116,7 @@ PERCONA_USER=homestead PERCONA_PASSWORD=secret PERCONA_PORT=3306 PERCONA_ROOT_PASSWORD=root +PERCONA_ENTRYPOINT_INITDB=./percona/docker-entrypoint-initdb.d ### MSSQL ############################################################################################################## @@ -115,6 +131,7 @@ MARIADB_USER=default MARIADB_PASSWORD=secret MARIADB_PORT=3306 MARIADB_ROOT_PASSWORD=root +MARIADB_ENTRYPOINT_INITDB=./mariadb/docker-entrypoint-initdb.d ### POSTGRES ########################################################################################################### @@ -136,6 +153,10 @@ RABBITMQ_DEFAULT_PASS=guest ELASTICSEARCH_HOST_HTTP_PORT=9200 ELASTICSEARCH_HOST_TRANSPORT_PORT=9300 +### KIBANA ############################################################################################################# + +KIBANA_HTTP_PORT=5601 + ### MEMCACHED ########################################################################################################## MEMCACHED_HOST_PORT=11211 @@ -161,6 +182,7 @@ MINIO_PORT=9000 ### ADMINER ############################################################################################################ ADM_PORT=8080 +ADM_INSTALL_MSSQL=false ### PHP MY ADMIN ####################################################################################################### @@ -239,6 +261,17 @@ CADDY_HOST_HTTPS_PORT=443 CADDY_HOST_LOG_PATH=./logs/caddy CADDY_CUSTOM_CADDYFILE=./caddy/Caddyfile +### LARAVEL ECHO SERVER ################################################################################################ + +LARAVEL_ECHO_SERVER_PORT=6001 + +### DOCKER-SYNC ################################################################################################ + +# osx: 'native_osx' (default) +# windows: 'unison' +# linux: docker-sync not required + +DOCKER_SYNC_STRATEGY=native_osx ##### TO BE CONTINUE ................................. @@ -246,8 +279,6 @@ CADDY_CUSTOM_CADDYFILE=./caddy/Caddyfile # ......... # ......... - - ############################ # Miscellaneous ############################ @@ -265,3 +296,4 @@ PHP_IDE_CONFIG=serverName=laradock # Fix for windows users to make sure the application path works. COMPOSE_CONVERT_WINDOWS_PATHS=1 + diff --git a/jenkins/install-plugins.sh b/jenkins/install-plugins.sh old mode 100644 new mode 100755 diff --git a/jenkins/jenkins-support b/jenkins/jenkins-support old mode 100644 new mode 100755 diff --git a/jenkins/jenkins.sh b/jenkins/jenkins.sh old mode 100644 new mode 100755 diff --git a/jenkins/plugins.sh b/jenkins/plugins.sh old mode 100644 new mode 100755 diff --git a/jenkins/publish.sh b/jenkins/publish.sh old mode 100644 new mode 100755 diff --git a/jenkins/update-official-library.sh b/jenkins/update-official-library.sh old mode 100644 new mode 100755 diff --git a/kibana/Dockerfile b/kibana/Dockerfile new file mode 100644 index 00000000..572f15ac --- /dev/null +++ b/kibana/Dockerfile @@ -0,0 +1,3 @@ +FROM docker.elastic.co/kibana/kibana:5.4.1 + +EXPOSE 5601 diff --git a/laravel-echo-server/Dockerfile b/laravel-echo-server/Dockerfile new file mode 100644 index 00000000..5074a1f8 --- /dev/null +++ b/laravel-echo-server/Dockerfile @@ -0,0 +1,15 @@ +FROM node:argon + +# Create app directory +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +# Install app dependencies +COPY package.json /usr/src/app/ +RUN npm install + +# Bundle app source +COPY laravel-echo-server.json /usr/src/app/laravel-echo-server.json + +EXPOSE 3000 +CMD [ "npm", "start" ] \ No newline at end of file diff --git a/laravel-echo-server/laravel-echo-server.json b/laravel-echo-server/laravel-echo-server.json new file mode 100644 index 00000000..0a98ef90 --- /dev/null +++ b/laravel-echo-server/laravel-echo-server.json @@ -0,0 +1,19 @@ +{ + "authHost": "localhost", + "authEndpoint": "/broadcasting/auth", + "clients": [], + "database": "redis", + "databaseConfig": { + "redis": { + "port": "6379", + "host": "redis" + } + }, + "devMode": true, + "host": null, + "port": "6001", + "protocol": "http", + "socketio": {}, + "sslCertPath": "", + "sslKeyPath": "" +} \ No newline at end of file diff --git a/laravel-echo-server/package.json b/laravel-echo-server/package.json new file mode 100644 index 00000000..2784a039 --- /dev/null +++ b/laravel-echo-server/package.json @@ -0,0 +1,12 @@ +{ + "name": "laravel-echo-server-docker", + "description": "Docker container for running laravel-echo-server", + "version": "0.0.1", + "license": "MIT", + "dependencies": { + "laravel-echo-server": "^1.2.8" + }, + "scripts": { + "start": "laravel-echo-server start" + } +} \ No newline at end of file diff --git a/mssql/create_table.sh b/mssql/create_table.sh index f0c1a7c6..9fe5214c 100644 --- a/mssql/create_table.sh +++ b/mssql/create_table.sh @@ -1,5 +1,5 @@ #wait for the SQL Server to come up -sleep 45s +sleep 45 #run the setup script to create the DB and the schema in the DB /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -d master -i setup.sql \ No newline at end of file diff --git a/mssql/entrypoint.sh b/mssql/entrypoint.sh index e3835130..062293b8 100644 --- a/mssql/entrypoint.sh +++ b/mssql/entrypoint.sh @@ -1,2 +1,2 @@ #start SQL Server, start the script to create the DB and import the data, start the app -/opt/mssql/bin/sqlservr.sh & /usr/src/app/create_table.sh & tail -f /dev/null \ No newline at end of file +/opt/mssql/bin/sqlservr & /usr/src/app/create_table.sh & tail -f /dev/null diff --git a/mysql/Dockerfile b/mysql/Dockerfile index e494b651..5eb6c40d 100644 --- a/mysql/Dockerfile +++ b/mysql/Dockerfile @@ -1,7 +1,16 @@ -FROM mysql:5.7 +ARG MYSQL_VERSION=8.0 +FROM mysql:${MYSQL_VERSION} MAINTAINER Mahmoud Zalt +##################################### +# Set Timezone +##################################### + +ARG TZ=UTC +ENV TZ ${TZ} +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + RUN chown -R mysql:root /var/lib/mysql/ ADD my.cnf /etc/mysql/conf.d/my.cnf diff --git a/mysql/docker-entrypoint-initdb.d/createdb.sql.example b/mysql/docker-entrypoint-initdb.d/createdb.sql.example index 2b7c5157..55679859 100644 --- a/mysql/docker-entrypoint-initdb.d/createdb.sql.example +++ b/mysql/docker-entrypoint-initdb.d/createdb.sql.example @@ -1,20 +1,20 @@ -### -### Copy createdb.sql.example to createdb.sql -### then uncomment then set database name and username to create you need databases +# +# Copy createdb.sql.example to createdb.sql +# then uncomment then set database name and username to create you need databases # # example: .env MYSQL_USER=appuser and need db name is myshop_db # # CREATE DATABASE IF NOT EXISTS `myshop_db` ; # GRANT ALL ON `myshop_db`.* TO 'appuser'@'%' ; # -### -### this sql script is auto run when mysql container start and $DATA_SAVE_PATH/mysql not exists. -### -### if your $DATA_SAVE_PATH/mysql is exists and you do not want to delete it, you can run by manual execution: -### -### docker-compose exec mysql bash -### mysql -u root -p < /docker-entrypoint-initdb.d/createdb.sql -### +# +# this sql script will auto run when the mysql container starts and the $DATA_SAVE_PATH/mysql not found. +# +# if your $DATA_SAVE_PATH/mysql exists and you do not want to delete it, you can run by manual execution: +# +# docker-compose exec mysql bash +# mysql -u root -p < /docker-entrypoint-initdb.d/createdb.sql +# #CREATE DATABASE IF NOT EXISTS `dev_db_1` COLLATE 'utf8_general_ci' ; #GRANT ALL ON `dev_db_1`.* TO 'default'@'%' ; diff --git a/mysql/my.cnf b/mysql/my.cnf index 06595ca5..bee678ab 100644 --- a/mysql/my.cnf +++ b/mysql/my.cnf @@ -7,3 +7,4 @@ [mysqld] sql-mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" +character-set-server=utf8 diff --git a/nginx/Dockerfile b/nginx/Dockerfile index e23be3d5..77f4abdd 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -4,7 +4,8 @@ MAINTAINER Mahmoud Zalt ADD nginx.conf /etc/nginx/ -ARG PHP_UPSTREAM=php-fpm +ARG PHP_UPSTREAM_CONTAINER=php-fpm +ARG PHP_UPSTREAM_PORT=9000 # fix a problem--#397, change application source from dl-cdn.alpinelinux.org to aliyun source. RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories @@ -12,9 +13,11 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories RUN apk update \ && apk upgrade \ && apk add --no-cache bash \ - && adduser -D -H -u 1000 -s /bin/bash www-data \ - && rm /etc/nginx/conf.d/default.conf \ - && echo "upstream php-upstream { server ${PHP_UPSTREAM}:9000; }" > /etc/nginx/conf.d/upstream.conf + && adduser -D -H -u 1000 -s /bin/bash www-data + +# Set upstream conf and remove the default conf +RUN echo "upstream php-upstream { server ${PHP_UPSTREAM_CONTAINER}:${PHP_UPSTREAM_PORT}; }" > /etc/nginx/conf.d/upstream.conf \ + && rm /etc/nginx/conf.d/default.conf CMD ["nginx"] diff --git a/nginx/nginx.conf b/nginx/nginx.conf index c627c4e1..e747e983 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -28,7 +28,7 @@ http { ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'; include /etc/nginx/conf.d/*.conf; - include /etc/nginx/sites-available/*; + include /etc/nginx/sites-available/*.conf; open_file_cache off; # Disabled for issue 619 charset UTF-8; } diff --git a/nginx/sites/project-1.conf.example b/nginx/sites/app.conf.example similarity index 82% rename from nginx/sites/project-1.conf.example rename to nginx/sites/app.conf.example index cf8872b7..c28eec30 100644 --- a/nginx/sites/project-1.conf.example +++ b/nginx/sites/app.conf.example @@ -3,8 +3,8 @@ server { listen 80; listen [::]:80; - server_name project-1.dev; - root /var/www/project-1/public; + server_name app.dev; + root /var/www/app; index index.php index.html index.htm; location / { @@ -29,4 +29,7 @@ server { root /var/www/letsencrypt/; log_not_found off; } + + error_log /var/log/nginx/app_error.log; + access_log /var/log/nginx/app_access.log; } diff --git a/nginx/sites/project-2.conf.example b/nginx/sites/laravel.conf.example similarity index 79% rename from nginx/sites/project-2.conf.example rename to nginx/sites/laravel.conf.example index cf495fec..dd9a2ae7 100644 --- a/nginx/sites/project-2.conf.example +++ b/nginx/sites/laravel.conf.example @@ -3,8 +3,8 @@ server { listen 80; listen [::]:80; - server_name project-2.dev; - root /var/www/project-2/public; + server_name laravel.dev; + root /var/www/laravel/public; index index.php index.html index.htm; location / { @@ -29,4 +29,7 @@ server { root /var/www/letsencrypt/; log_not_found off; } + + error_log /var/log/nginx/laravel_error.log; + access_log /var/log/nginx/laravel_access.log; } diff --git a/nginx/sites/symfony.conf.example b/nginx/sites/symfony.conf.example new file mode 100644 index 00000000..8d518fee --- /dev/null +++ b/nginx/sites/symfony.conf.example @@ -0,0 +1,28 @@ +server { + + listen 80; + listen [::]:80; + + server_name symfony.dev; + root /var/www/projects/symfony/web; + index index.php index.html index.htm; + + location / { + try_files $uri @rewriteapp; + } + + location @rewriteapp { + rewrite ^(.*)$ /app.php/$1 last; + } + + location ~ ^/(app|app_dev|config)\.php(/|$) { + fastcgi_pass php-upstream; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param HTTPS off; + } + + error_log /var/log/nginx/symfony_error.log; + access_log /var/log/nginx/symfony_access.log; +} diff --git a/pgadmin/Dockerfile b/pgadmin/Dockerfile index 2d34c22b..5836801f 100644 --- a/pgadmin/Dockerfile +++ b/pgadmin/Dockerfile @@ -1,5 +1,10 @@ FROM fenglc/pgadmin4 -MAINTAINER Bo-Yi Wu +MAINTAINER Huadong Zuo + +# user: pgadmin4@pgadmin.org +# password: admin +# pg_dump in "/usr/bin" +# backup in "/var/lib/pgadmin4/data/storage/pgadmin4/" EXPOSE 5050 diff --git a/php-fpm/Dockerfile-56 b/php-fpm/Dockerfile-56 index 1ce3276f..1d8fd976 100644 --- a/php-fpm/Dockerfile-56 +++ b/php-fpm/Dockerfile-56 @@ -246,6 +246,29 @@ RUN if [ ${INSTALL_LDAP} = true ]; then \ docker-php-ext-install ldap \ ;fi +##################################### +# SQL SERVER: +##################################### +ARG INSTALL_MSSQL=false +ENV INSTALL_MSSQL ${INSTALL_MSSQL} + +RUN if [ ${INSTALL_MSSQL} = true ]; then \ + apt-get -y install php5-sybase freetds-bin && \ + cp /usr/lib/php5/20131226/*.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/ && \ + docker-php-ext-enable mssql pdo pdo_dblib \ +;fi + +##################################### +# Image optimizers: +##################################### +USER root +ARG INSTALL_IMAGE_OPTIMIZERS=false +ENV INSTALL_IMAGE_OPTIMIZERS ${INSTALL_IMAGE_OPTIMIZERS} +RUN if [ ${INSTALL_IMAGE_OPTIMIZERS} = true ]; then \ + apt-get update -yqq && \ + apt-get install -y --force-yes jpegoptim optipng pngquant gifsicle \ +;fi + # #-------------------------------------------------------------------------- # Final Touch diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index b14adacb..b643a384 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -282,6 +282,17 @@ RUN if [ ${INSTALL_MSSQL} = true ]; then \ && docker-php-ext-enable pdo_sqlsrv sqlsrv \ ;fi +##################################### +# Image optimizers: +##################################### +USER root +ARG INSTALL_IMAGE_OPTIMIZERS=false +ENV INSTALL_IMAGE_OPTIMIZERS ${INSTALL_IMAGE_OPTIMIZERS} +RUN if [ ${INSTALL_IMAGE_OPTIMIZERS} = true ]; then \ + apt-get update -yqq && \ + apt-get install -y --force-yes jpegoptim optipng pngquant gifsicle \ +;fi + # #-------------------------------------------------------------------------- # Final Touch diff --git a/php-fpm/Dockerfile-71 b/php-fpm/Dockerfile-71 index 3a71dc21..90ea2bd0 100644 --- a/php-fpm/Dockerfile-71 +++ b/php-fpm/Dockerfile-71 @@ -289,6 +289,17 @@ RUN if [ ${INSTALL_MSSQL} = true ]; then \ && docker-php-ext-enable pdo_sqlsrv sqlsrv \ ;fi +##################################### +# Image optimizers: +##################################### +USER root +ARG INSTALL_IMAGE_OPTIMIZERS=false +ENV INSTALL_IMAGE_OPTIMIZERS ${INSTALL_IMAGE_OPTIMIZERS} +RUN if [ ${INSTALL_IMAGE_OPTIMIZERS} = true ]; then \ + apt-get update -yqq && \ + apt-get install -y --force-yes jpegoptim optipng pngquant gifsicle \ +;fi + # #-------------------------------------------------------------------------- # Final Touch diff --git a/php-worker/Dockerfile b/php-worker/Dockerfile-70 similarity index 65% rename from php-worker/Dockerfile rename to php-worker/Dockerfile-70 index 58de7d5b..8b7dd601 100644 --- a/php-worker/Dockerfile +++ b/php-worker/Dockerfile-70 @@ -3,14 +3,30 @@ # Image Setup #-------------------------------------------------------------------------- # -# To take a look at the'php-worker' base Image, visit its DockerHub page -# https://hub.docker.com/r/nielsvdoorn/laravel-supervisor/ -# -FROM nielsvdoorn/laravel-supervisor +FROM php:7.0-alpine MAINTAINER Mahmoud Zalt +RUN apk --update add wget \ + curl \ + git \ + build-base \ + libmemcached-dev \ + libmcrypt-dev \ + libxml2-dev \ + zlib-dev \ + autoconf \ + cyrus-sasl-dev \ + libgsasl-dev \ + supervisor + +RUN docker-php-ext-install mysqli mbstring pdo pdo_mysql mcrypt tokenizer xml +RUN pecl channel-update pecl.php.net && pecl install memcached && docker-php-ext-enable memcached + +RUN rm /var/cache/apk/* \ + && mkdir -p /var/www + # #-------------------------------------------------------------------------- # Optional Supervisord Configuration @@ -19,7 +35,10 @@ MAINTAINER Mahmoud Zalt # Modify the ./supervisor.conf file to match your App's requirements. # Make sure you rebuild your container with every change. # -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +COPY supervisord.conf /etc/supervisord.conf + +ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"] # #-------------------------------------------------------------------------- @@ -37,5 +56,4 @@ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf #-------------------------------------------------------------------------- # -RUN rm -r /var/lib/apt/lists/* WORKDIR /etc/supervisor/conf.d/ diff --git a/php-worker/Dockerfile-71 b/php-worker/Dockerfile-71 new file mode 100644 index 00000000..697efb67 --- /dev/null +++ b/php-worker/Dockerfile-71 @@ -0,0 +1,59 @@ +# +#-------------------------------------------------------------------------- +# Image Setup +#-------------------------------------------------------------------------- +# + +FROM php:7.1-alpine + +MAINTAINER Mahmoud Zalt + +RUN apk --update add wget \ + curl \ + git \ + build-base \ + libmemcached-dev \ + libmcrypt-dev \ + libxml2-dev \ + zlib-dev \ + autoconf \ + cyrus-sasl-dev \ + libgsasl-dev \ + supervisor + +RUN docker-php-ext-install mysqli mbstring pdo pdo_mysql mcrypt tokenizer xml +RUN pecl channel-update pecl.php.net && pecl install memcached && docker-php-ext-enable memcached + +RUN rm /var/cache/apk/* \ + && mkdir -p /var/www + +# +#-------------------------------------------------------------------------- +# Optional Supervisord Configuration +#-------------------------------------------------------------------------- +# +# Modify the ./supervisor.conf file to match your App's requirements. +# Make sure you rebuild your container with every change. +# + +COPY supervisord.conf /etc/supervisord.conf + +ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"] + +# +#-------------------------------------------------------------------------- +# Optional Software's Installation +#-------------------------------------------------------------------------- +# +# If you need to modify this image, feel free to do it right here. +# + # -- Your awesome modifications go here -- # + + +# +#-------------------------------------------------------------------------- +# Final Touch +#-------------------------------------------------------------------------- +# + +WORKDIR /etc/supervisor/conf.d/ diff --git a/sync.sh b/sync.sh new file mode 100755 index 00000000..6955358d --- /dev/null +++ b/sync.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +# This shell script is an optional tool to simplify +# the installation and usage of laradock with docker-sync. + +# Make sure that the DOCKER_SYNC_STRATEGY is set in the .env +# DOCKER_SYNC_STRATEGY=native_osx # osx +# DOCKER_SYNC_STRATEGY=unison # windows + +# To run, make sure to add permissions to this file: +# chmod 755 sync.sh + +# USAGE EXAMPLE: +# Install docker-sync: ./sync.sh install +# Start sync and services with nginx and mysql: ./sync.sh up nginx mysql +# Stop containers and sync: ./sync.sh down + +# prints colored text +print_style () { + + if [ "$2" == "info" ] ; then + COLOR="96m" + elif [ "$2" == "success" ] ; then + COLOR="92m" + elif [ "$2" == "warning" ] ; then + COLOR="93m" + elif [ "$2" == "danger" ] ; then + COLOR="91m" + else #default color + COLOR="0m" + fi + + STARTCOLOR="\e[$COLOR" + ENDCOLOR="\e[0m" + + printf "$STARTCOLOR%b$ENDCOLOR" "$1" +} + +display_options () { + printf "Available options:\n"; + print_style " install" "info"; printf "\t\t Installs docker-sync gem on the host machine.\n" + print_style " up [services]" "success"; printf "\t Starts docker-sync and runs docker compose.\n" + print_style " down" "success"; printf "\t\t\t Stops containers and docker-sync.\n" + print_style " bash" "success"; printf "\t\t\t Opens bash on the workspace.\n" + print_style " sync" "info"; printf "\t\t\t Manually triggers the synchronization of files.\n" + print_style " clean" "danger"; printf "\t\t Removes all files from docker-sync.\n" +} + +if [[ $# -eq 0 ]] ; then + print_style "Missing arguments.\n" "danger" + display_options + exit 1 +fi + +if [ "$1" == "up" ] ; then + print_style "Initializing Docker Sync\n" "info" + print_style "May take a long time (15min+) on the first run\n" "info" + docker-sync start; + + print_style "Initializing Docker Compose\n" "info" + shift # removing first argument + docker-compose -f docker-compose.yml -f docker-compose.sync.yml up -d ${@} + +elif [ "$1" == "down" ]; then + print_style "Stopping Docker Compose\n" "info" + docker-compose down + + print_style "Stopping Docker Sync\n" "info" + docker-sync stop + +elif [ "$1" == "bash" ]; then + docker-compose exec workspace bash + +elif [ "$1" == "install" ]; then + print_style "Installing docker-sync\n" "info" + gem install docker-sync + +elif [ "$1" == "sync" ]; then + print_style "Manually triggering sync between host and docker-sync container.\n" "info" + docker-sync sync; + +elif [ "$1" == "clean" ]; then + print_style "Removing and cleaning up files from the docker-sync container.\n" "warning" + docker-sync clean +else + print_style "Invalid arguments.\n" "danger" + display_options + exit 1 +fi \ No newline at end of file diff --git a/travis-build.sh b/travis-build.sh index fa7e5773..c72f51df 100755 --- a/travis-build.sh +++ b/travis-build.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash #### halt script on error -set -e +set -xe echo '##### Print docker version' docker --version @@ -26,7 +26,7 @@ if [ -n "${HUGO_VERSION}" ]; then # Download hugo binary curl -L https://github.com/spf13/hugo/releases/download/v$HUGO_VERSION/$HUGO_PACKAGE.tar.gz | tar xz - mkdir $HOME/bin + mkdir -p $HOME/bin mv ./${HUGO_BIN}/${HUGO_BIN} $HOME/bin/hugo # Remove existing docs diff --git a/workspace/Dockerfile-56 b/workspace/Dockerfile-56 index 42d0256b..a5ba7889 100644 --- a/workspace/Dockerfile-56 +++ b/workspace/Dockerfile-56 @@ -117,13 +117,17 @@ COPY ./aliases.sh /home/laradock/aliases.sh RUN echo "" >> ~/.bashrc && \ echo "# Load Custom Aliases" >> ~/.bashrc && \ echo "source /home/laradock/aliases.sh" >> ~/.bashrc && \ - echo "" >> ~/.bashrc + echo "" >> ~/.bashrc && \ + sed -i 's/\r//' /home/laradock/aliases.sh && \ + sed -i 's/^#! \/bin\/sh/#! \/bin\/bash/' /home/laradock/aliases.sh USER root RUN echo "" >> ~/.bashrc && \ echo "# Load Custom Aliases" >> ~/.bashrc && \ echo "source /home/laradock/aliases.sh" >> ~/.bashrc && \ - echo "" >> ~/.bashrc + echo "" >> ~/.bashrc && \ + sed -i 's/\r//' /home/laradock/aliases.sh && \ + sed -i 's/^#! \/bin\/sh/#! \/bin\/bash/' /home/laradock/aliases.sh ##################################### # xDebug: @@ -186,7 +190,8 @@ ENV INSTALL_MONGO ${INSTALL_MONGO} RUN if [ ${INSTALL_MONGO} = true ]; then \ # Install the mongodb extension pecl install mongodb && \ - echo "extension=mongodb.so" >> /etc/php/5.6/cli/conf.d/30-mongodb.ini \ + echo "extension=mongodb.so" >> /etc/php/5.6/mods-available/mongodb.ini && \ + ln -s /etc/php/5.6/mods-available/mongodb.ini /etc/php/5.6/cli/conf.d/30-mongodb.ini \ ;fi ##################################### @@ -197,12 +202,28 @@ ENV DRUSH_VERSION 8.1.2 ARG INSTALL_DRUSH=false ENV INSTALL_DRUSH ${INSTALL_DRUSH} RUN if [ ${INSTALL_DRUSH} = true ]; then \ + apt-get update -yqq && \ + apt-get -y install mysql-client && \ # Install Drush 8 with the phar file. curl -fsSL -o /usr/local/bin/drush https://github.com/drush-ops/drush/releases/download/$DRUSH_VERSION/drush.phar | bash && \ chmod +x /usr/local/bin/drush && \ drush core-status \ ;fi +##################################### +# Drupal Console: +##################################### +USER root +ARG INSTALL_DRUPAL_CONSOLE=false +ENV INSTALL_DRUPAL_CONSOLE ${INSTALL_DRUPAL_CONSOLE} +RUN if [ ${INSTALL_DRUPAL_CONSOLE} = true ]; then \ + apt-get update -yqq && \ + apt-get -y install mysql-client && \ + curl https://drupalconsole.com/installer -L -o drupal.phar && \ + mv drupal.phar /usr/local/bin/drupal && \ + chmod +x /usr/local/bin/drupal \ +;fi + USER laradock ##################################### @@ -312,14 +333,6 @@ USER laradock RUN echo "" >> ~/.bashrc && \ echo 'export PATH="/var/www/vendor/bin:$PATH"' >> ~/.bashrc -##################################### -# Laravel Artisan Alias -##################################### -USER root - -RUN echo "" >> ~/.bashrc && \ - echo 'alias art="php artisan"' >> ~/.bashrc - ##################################### # Laravel Envoy: ##################################### @@ -333,6 +346,23 @@ RUN if [ ${INSTALL_LARAVEL_ENVOY} = true ]; then \ composer global require "laravel/envoy=~1.0" \ ;fi +##################################### +# Laravel Installer: +##################################### +USER root + +ARG INSTALL_LARAVEL_INSTALLER=true +ENV INSTALL_LARAVEL_INSTALLER ${INSTALL_LARAVEL_INSTALLER} + +RUN if [ ${INSTALL_LARAVEL_INSTALLER} = true ]; then \ + # Install the Laravel Installer + echo "" >> ~/.bashrc && \ + echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc \ + && composer global require "laravel/installer" \ +;fi + +USER laradock + ##################################### # Deployer: ##################################### @@ -378,6 +408,17 @@ RUN if [ ${INSTALL_LINUXBREW} = true ]; then \ echo 'export LD_LIBRARY_PATH="$LINUXBREWHOME/lib64:$LINUXBREWHOME/lib:$LD_LIBRARY_PATH"' >> ~/.bashrc \ ;fi +##################################### +# SQL SERVER: +##################################### +ARG INSTALL_MSSQL=false +ENV INSTALL_MSSQL ${INSTALL_MSSQL} + +RUN if [ ${INSTALL_MSSQL} = true ]; then \ + apt-get -y install php5.6-sybase freetds-bin freetds-common libsybdb5 \ + && echo "extension=pdo_dblib.so" > /etc/php/5.6/cli/conf.d/20-pdo_dblib.ini \ +;fi + ##################################### # Minio: ##################################### @@ -392,8 +433,56 @@ RUN if [ ${INSTALL_MC} = true ]; then\ chmod +x /usr/local/bin/mc \ ;fi +##################################### +# Image optimizers: +##################################### +USER root +ARG INSTALL_IMAGE_OPTIMIZERS=false +ENV INSTALL_IMAGE_OPTIMIZERS ${INSTALL_IMAGE_OPTIMIZERS} +RUN if [ ${INSTALL_IMAGE_OPTIMIZERS} = true ]; then \ + apt-get install -y --force-yes jpegoptim optipng pngquant gifsicle && \ + if [ ${INSTALL_NODE} = true ]; then \ + . ~/.bashrc && npm install -g svgo \ + ;fi\ +;fi + USER laradock +##################################### +# Symfony: +##################################### +USER root +ARG INSTALL_SYMFONY=false +ENV INSTALL_SYMFONY ${INSTALL_SYMFONY} +RUN if [ ${INSTALL_SYMFONY} = true ]; then \ + + mkdir -p /usr/local/bin \ + && curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony \ + && chmod a+x /usr/local/bin/symfony \ + + # Symfony 3 alias + && echo 'alias dev="php bin/console -e=dev"' >> ~/.bashrc \ + && echo 'alias prod="php bin/console -e=prod"' >> ~/.bashrc \ + + # Symfony 2 alias + # && echo 'alias dev="php app/console -e=dev"' >> ~/.bashrc \ + # && echo 'alias prod="php app/console -e=prod"' >> ~/.bashrc \ + +;fi + +##################################### +# PYTHON: +##################################### + +ARG INSTALL_PYTHON=false +ENV INSTALL_PYTHON ${INSTALL_PYTHON} +RUN if [ ${INSTALL_PYTHON} = true ]; then \ + apt-get update \ + && apt-get -y install python python-pip python-dev build-essential \ + && pip install --upgrade pip \ + && pip install --upgrade virtualenv \ +;fi + # #-------------------------------------------------------------------------- # Final Touch diff --git a/workspace/Dockerfile-70 b/workspace/Dockerfile-70 index 9c7d5627..3d1cde55 100644 --- a/workspace/Dockerfile-70 +++ b/workspace/Dockerfile-70 @@ -117,13 +117,17 @@ COPY ./aliases.sh /home/laradock/aliases.sh RUN echo "" >> ~/.bashrc && \ echo "# Load Custom Aliases" >> ~/.bashrc && \ echo "source /home/laradock/aliases.sh" >> ~/.bashrc && \ - echo "" >> ~/.bashrc + echo "" >> ~/.bashrc && \ + sed -i 's/\r//' /home/laradock/aliases.sh && \ + sed -i 's/^#! \/bin\/sh/#! \/bin\/bash/' /home/laradock/aliases.sh USER root RUN echo "" >> ~/.bashrc && \ echo "# Load Custom Aliases" >> ~/.bashrc && \ echo "source /home/laradock/aliases.sh" >> ~/.bashrc && \ - echo "" >> ~/.bashrc + echo "" >> ~/.bashrc && \ + sed -i 's/\r//' /home/laradock/aliases.sh && \ + sed -i 's/^#! \/bin\/sh/#! \/bin\/bash/' /home/laradock/aliases.sh ##################################### # xDebug: @@ -186,7 +190,8 @@ ENV INSTALL_MONGO ${INSTALL_MONGO} RUN if [ ${INSTALL_MONGO} = true ]; then \ # Install the mongodb extension pecl install mongodb && \ - echo "extension=mongodb.so" >> /etc/php/7.0/cli/conf.d/30-mongodb.ini \ + echo "extension=mongodb.so" >> /etc/php/7.0/mods-available/mongodb.ini && \ + ln -s /etc/php/7.0/mods-available/mongodb.ini /etc/php/7.0/cli/conf.d/30-mongodb.ini \ ;fi ##################################### @@ -197,12 +202,28 @@ ENV DRUSH_VERSION 8.1.2 ARG INSTALL_DRUSH=false ENV INSTALL_DRUSH ${INSTALL_DRUSH} RUN if [ ${INSTALL_DRUSH} = true ]; then \ + apt-get update -yqq && \ + apt-get -y install mysql-client && \ # Install Drush 8 with the phar file. curl -fsSL -o /usr/local/bin/drush https://github.com/drush-ops/drush/releases/download/$DRUSH_VERSION/drush.phar | bash && \ chmod +x /usr/local/bin/drush && \ drush core-status \ ;fi +##################################### +# Drupal Console: +##################################### +USER root +ARG INSTALL_DRUPAL_CONSOLE=false +ENV INSTALL_DRUPAL_CONSOLE ${INSTALL_DRUPAL_CONSOLE} +RUN if [ ${INSTALL_DRUPAL_CONSOLE} = true ]; then \ + apt-get update -yqq && \ + apt-get -y install mysql-client && \ + curl https://drupalconsole.com/installer -L -o drupal.phar && \ + mv drupal.phar /usr/local/bin/drupal && \ + chmod +x /usr/local/bin/drupal \ +;fi + USER laradock ##################################### @@ -329,14 +350,6 @@ USER laradock RUN echo "" >> ~/.bashrc && \ echo 'export PATH="/var/www/vendor/bin:$PATH"' >> ~/.bashrc -##################################### -# Laravel Artisan Alias -##################################### -USER root - -RUN echo "" >> ~/.bashrc && \ - echo 'alias art="php artisan"' >> ~/.bashrc - ##################################### # Laravel Envoy: ##################################### @@ -350,6 +363,23 @@ RUN if [ ${INSTALL_LARAVEL_ENVOY} = true ]; then \ composer global require "laravel/envoy=~1.0" \ ;fi +##################################### +# Laravel Installer: +##################################### +USER root + +ARG INSTALL_LARAVEL_INSTALLER=true +ENV INSTALL_LARAVEL_INSTALLER ${INSTALL_LARAVEL_INSTALLER} + +RUN if [ ${INSTALL_LARAVEL_INSTALLER} = true ]; then \ + # Install the Laravel Installer + echo "" >> ~/.bashrc && \ + echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc \ + && composer global require "laravel/installer" \ +;fi + +USER laradock + ##################################### # Deployer: ##################################### @@ -486,6 +516,19 @@ RUN if [ ${INSTALL_MC} = true ]; then\ chmod +x /usr/local/bin/mc \ ;fi +##################################### +# Image optimizers: +##################################### +USER root +ARG INSTALL_IMAGE_OPTIMIZERS=false +ENV INSTALL_IMAGE_OPTIMIZERS ${INSTALL_IMAGE_OPTIMIZERS} +RUN if [ ${INSTALL_IMAGE_OPTIMIZERS} = true ]; then \ + apt-get install -y --force-yes jpegoptim optipng pngquant gifsicle && \ + if [ ${INSTALL_NODE} = true ]; then \ + . ~/.bashrc && npm install -g svgo \ + ;fi\ +;fi + ##################################### # Symfony: ##################################### @@ -508,6 +551,19 @@ RUN if [ ${INSTALL_SYMFONY} = true ]; then \ ;fi +##################################### +# PYTHON: +##################################### + +ARG INSTALL_PYTHON=false +ENV INSTALL_PYTHON ${INSTALL_PYTHON} +RUN if [ ${INSTALL_PYTHON} = true ]; then \ + apt-get update \ + && apt-get -y install python python-pip python-dev build-essential \ + && pip install --upgrade pip \ + && pip install --upgrade virtualenv \ +;fi + # #-------------------------------------------------------------------------- # Final Touch diff --git a/workspace/Dockerfile-71 b/workspace/Dockerfile-71 index 71d865b3..b0320e6b 100644 --- a/workspace/Dockerfile-71 +++ b/workspace/Dockerfile-71 @@ -113,13 +113,17 @@ COPY ./aliases.sh /home/laradock/aliases.sh RUN echo "" >> ~/.bashrc && \ echo "# Load Custom Aliases" >> ~/.bashrc && \ echo "source /home/laradock/aliases.sh" >> ~/.bashrc && \ - echo "" >> ~/.bashrc + echo "" >> ~/.bashrc && \ + sed -i 's/\r//' /home/laradock/aliases.sh && \ + sed -i 's/^#! \/bin\/sh/#! \/bin\/bash/' /home/laradock/aliases.sh USER root RUN echo "" >> ~/.bashrc && \ echo "# Load Custom Aliases" >> ~/.bashrc && \ echo "source /home/laradock/aliases.sh" >> ~/.bashrc && \ - echo "" >> ~/.bashrc + echo "" >> ~/.bashrc && \ + sed -i 's/\r//' /home/laradock/aliases.sh && \ + sed -i 's/^#! \/bin\/sh/#! \/bin\/bash/' /home/laradock/aliases.sh ##################################### # xDebug: @@ -128,7 +132,8 @@ RUN echo "" >> ~/.bashrc && \ ARG INSTALL_XDEBUG=false RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # Load the xdebug extension only with phpunit commands - apt-get install -y --force-yes php-xdebug && \ + apt-get update && \ + apt-get install -y --force-yes php7.1-xdebug && \ sed -i 's/^;//g' /etc/php/7.1/cli/conf.d/20-xdebug.ini && \ echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/vendor/bin/phpunit'" >> ~/.bashrc \ ;fi @@ -182,7 +187,8 @@ ENV INSTALL_MONGO ${INSTALL_MONGO} RUN if [ ${INSTALL_MONGO} = true ]; then \ # Install the mongodb extension pecl install mongodb && \ - echo "extension=mongodb.so" >> /etc/php/7.1/cli/conf.d/30-mongodb.ini \ + echo "extension=mongodb.so" >> /etc/php/7.1/mods-available/mongodb.ini && \ + ln -s /etc/php/7.1/mods-available/mongodb.ini /etc/php/7.1/cli/conf.d/30-mongodb.ini \ ;fi ##################################### @@ -193,12 +199,28 @@ ENV DRUSH_VERSION 8.1.2 ARG INSTALL_DRUSH=false ENV INSTALL_DRUSH ${INSTALL_DRUSH} RUN if [ ${INSTALL_DRUSH} = true ]; then \ + apt-get update -yqq && \ + apt-get -y install mysql-client && \ # Install Drush 8 with the phar file. curl -fsSL -o /usr/local/bin/drush https://github.com/drush-ops/drush/releases/download/$DRUSH_VERSION/drush.phar | bash && \ chmod +x /usr/local/bin/drush && \ drush core-status \ ;fi +##################################### +# Drupal Console: +##################################### +USER root +ARG INSTALL_DRUPAL_CONSOLE=false +ENV INSTALL_DRUPAL_CONSOLE ${INSTALL_DRUPAL_CONSOLE} +RUN if [ ${INSTALL_DRUPAL_CONSOLE} = true ]; then \ + apt-get update -yqq && \ + apt-get -y install mysql-client && \ + curl https://drupalconsole.com/installer -L -o drupal.phar && \ + mv drupal.phar /usr/local/bin/drupal && \ + chmod +x /usr/local/bin/drupal \ +;fi + USER laradock ##################################### @@ -329,20 +351,12 @@ USER laradock RUN echo "" >> ~/.bashrc && \ echo 'export PATH="/var/www/vendor/bin:$PATH"' >> ~/.bashrc -##################################### -# Laravel Artisan Alias -##################################### -USER root - -RUN echo "" >> ~/.bashrc && \ - echo 'alias art="php artisan"' >> ~/.bashrc - ##################################### # Laravel Envoy: ##################################### USER laradock -ARG INSTALL_LARAVEL_ENVOY=true +ARG INSTALL_LARAVEL_ENVOY=false ENV INSTALL_LARAVEL_ENVOY ${INSTALL_LARAVEL_ENVOY} RUN if [ ${INSTALL_LARAVEL_ENVOY} = true ]; then \ @@ -350,6 +364,23 @@ RUN if [ ${INSTALL_LARAVEL_ENVOY} = true ]; then \ composer global require "laravel/envoy=~1.0" \ ;fi +##################################### +# Laravel Installer: +##################################### +USER root + +ARG INSTALL_LARAVEL_INSTALLER=false +ENV INSTALL_LARAVEL_INSTALLER ${INSTALL_LARAVEL_INSTALLER} + +RUN if [ ${INSTALL_LARAVEL_INSTALLER} = true ]; then \ + # Install the Laravel Installer + echo "" >> ~/.bashrc && \ + echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc \ + && composer global require "laravel/installer" \ +;fi + +USER laradock + ##################################### # Deployer: ##################################### @@ -368,7 +399,7 @@ RUN if [ ${INSTALL_DEPLOYER} = true ]; then \ ##################################### USER root -ARG INSTALL_LINUXBREW=true +ARG INSTALL_LINUXBREW=false ENV INSTALL_LINUXBREW ${INSTALL_LINUXBREW} RUN if [ ${INSTALL_LINUXBREW} = true ]; then \ @@ -398,7 +429,7 @@ RUN if [ ${INSTALL_LINUXBREW} = true ]; then \ ##################################### # SQL SERVER: ##################################### -ARG INSTALL_MSSQL=true +ARG INSTALL_MSSQL=false ENV INSTALL_MSSQL ${INSTALL_MSSQL} RUN if [ ${INSTALL_MSSQL} = true ]; then \ @@ -488,6 +519,21 @@ RUN if [ ${INSTALL_MC} = true ]; then\ chmod +x /usr/local/bin/mc \ ;fi +##################################### +# Image optimizers: +##################################### +USER root +ARG INSTALL_IMAGE_OPTIMIZERS=false +ENV INSTALL_IMAGE_OPTIMIZERS ${INSTALL_IMAGE_OPTIMIZERS} +RUN if [ ${INSTALL_IMAGE_OPTIMIZERS} = true ]; then \ + apt-get install -y --force-yes jpegoptim optipng pngquant gifsicle && \ + if [ ${INSTALL_NODE} = true ]; then \ + . ~/.bashrc && npm install -g svgo \ + ;fi\ +;fi + +USER laradock + ##################################### # Symfony: ##################################### @@ -510,7 +556,19 @@ RUN if [ ${INSTALL_SYMFONY} = true ]; then \ ;fi -USER laradock +##################################### +# PYTHON: +##################################### + +ARG INSTALL_PYTHON=false +ENV INSTALL_PYTHON ${INSTALL_PYTHON} +RUN if [ ${INSTALL_PYTHON} = true ]; then \ + apt-get update \ + && apt-get -y install python python-pip python-dev build-essential \ + && pip install --upgrade pip \ + && pip install --upgrade virtualenv \ +;fi + # #-------------------------------------------------------------------------- diff --git a/workspace/aliases.sh b/workspace/aliases.sh index f3e2a2c0..1bf21c65 100644 --- a/workspace/aliases.sh +++ b/workspace/aliases.sh @@ -10,23 +10,54 @@ COL_BLUE=$ESC_SEQ"34;01m" COL_MAGENTA=$ESC_SEQ"35;01m" COL_CYAN=$ESC_SEQ"36;01m" +# Detect which `ls` flavor is in use +if ls --color > /dev/null 2>&1; then # GNU `ls` + colorflag="--color" + export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:' +else # macOS `ls` + colorflag="-G" + export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx' +fi + +# List all files colorized in long format +#alias l="ls -lF ${colorflag}" +### MEGA: I want l and la ti return hisdden files +alias l="ls -laF ${colorflag}" + +# List all files colorized in long format, including dot files +alias la="ls -laF ${colorflag}" + +# List only directories +alias lsd="ls -lF ${colorflag} | grep --color=never '^d'" + +# Always use color output for `ls` +alias ls="command ls ${colorflag}" + # Commonly Used Aliases alias ..="cd .." +alias ...="cd ../.." +alias ....="cd ../../.." +alias .....="cd ../../../.." +alias ~="cd ~" # `cd` is probably faster to type though +alias -- -="cd -" +alias home="cd ~" + +alias h="history" +alias j="jobs" +alias e='exit' alias c="clear" alias cla="clear && ls -l" alias cll="clear && ls -la" alias cls="clear && ls" alias code="cd /var/www" alias ea="vi ~/aliases" -alias g="gulp" -alias home="cd ~" -alias npm-global="npm list -g --depth 0" -alias ra="reload" -alias reload="source ~/.aliases && echo \"$COL_GREEN ==> Aliases Reloaded... $COL_RESET \n \"" -alias run="npm run" -alias tree="xtree" -# Laravel / PHP Alisases +# Always enable colored `grep` output +# Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage. +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' + alias art="php artisan" alias artisan="php artisan" alias cdump="composer dump-autoload -o" @@ -34,18 +65,31 @@ alias composer:dump="composer dump-autoload -o" alias db:reset="php artisan migrate:reset && php artisan migrate --seed" alias migrate="php artisan migrate" alias seed="php artisan:seed" -alias phpunit="./vendor/bin/phpunit" +alias phpunit="./vendor/bin/phpunit" +alias pu="phpunit" +alias puf="phpunit --filter" +alias pud='phpunit --debug' + +alias cc='codecept' +alias ccb='codecept build' +alias ccr='codecept run' +alias ccu='codecept run unit' +alias ccf='codecept run functional' + +alias g="gulp" +alias npm-global="npm list -g --depth 0" +alias ra="reload" +alias reload="source ~/.aliases && echo \"$COL_GREEN ==> Aliases Reloaded... $COL_RESET \n \"" +alias run="npm run" +alias tree="xtree" # 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' alias pm="package-menu" - # requires installation of 'https://www.npmjs.com/package/pkg-version-cli' alias pv="package-version" - # requires installation of 'https://github.com/sindresorhus/latest-version-cli' alias lv="latest-version" @@ -56,7 +100,6 @@ alias git-revert="git reset --hard && git clean -df" alias gs="git status" alias whoops="git reset --hard && git clean -df" - # Create a new directory and enter it function mkd() { mkdir -p "$@" && cd "$@" @@ -69,3 +112,25 @@ function md() { function xtree { find ${1:-.} -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' } + +# `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring +# the `.git` directory, listing directories first. The output gets piped into +# `less` with options to preserve color and line numbers, unless the output is +# small enough for one screen. +function tre() { + tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX; +} + +# Determine size of a file or total size of a directory +function fs() { + if du -b /dev/null > /dev/null 2>&1; then + local arg=-sbh; + else + local arg=-sh; + fi + if [[ -n "$@" ]]; then + du $arg -- "$@"; + else + du $arg .[^.]* ./*; + fi; +}