This is an example repository of a "Dockerized" application, as covered on the Dockerizing Your Application preview series from shippingdocker.com.
# Get repo
git clone https://github.com/shipping-docker/dockerized-app.git
cd dockerized-app
# Build app/node images
./develop build
# Get laravel requirements
./develop composer install
./develop npm install
# Spin up Laravel (defaults to binding to port 80)
./develop up -d
# Alternatively, bind to port 8888 (or any other port)
APP_PORT=8888 ./develop up -d
# Run tests
./develop test
You may need to create a .env
file with the following modified from the .env.example
file (don't forget to also run ./develop art key:generate
):
APP_KEY=SOME-KEY-HERE
DB_HOST=mysql
CACHE_DRIVER=redis
SESSION_DRIVER=redis
REDIS_HOST=redis
- Docker Compose configuration for dev vs ci environments
develop
helper to run commands against your application, and to more easily usedocker-compose
- Dynamically decide to load xDebug module based on
APP_ENV
- Environment considerations for running within CI (e.g. Jenkins)
- Docker builds for
app
container (Nginx+PHP+composer),node
contaienr (npm, node, suitable for gulp)
The develop
command helper provides the following commands:
art
command
Run artisan
commands within an app
container.
./develop art [...]
# e.g.
./develop art make:controller -h
composer
command
Run composer
command within an app
container.
./develop composer [...]
# e.g.
./develop composer require predis/predis
test
command
Run phpunit
command within an app
container.
./develop test [...]
# e.g.
./develop test
./develop test tests/unit/SpecificFileToTest.php
./develop test --filter 'TestNamespace\\TestCaseClass::testMethod'
Run phpunit
command within an already-running app
container. This is quicker as it uses exec
to run a command inside a running container, instead of run
to spin up a new container.
./develop t [...]
# e.g.
./develop t
./develop t tests/unit/SpecificFileToTest.php
./develop t --filter 'TestNamespace\\TestCaseClass::testMethod'
npm
command
Run npm
commands within a node
container.
./develop npm [...]
# e.g.
./develop npm install
./develop npm install --save gulp
gulp
command
Run gulp
commands within a node
container.
./develop gulp [...]
# e.g.
./develop gulp
./develop gulp --production
docker-compose
command
Any command not matching above falls back to running docker-compose
.
./develop [...]
# e.g.
./develop ps
./develop up -d
./develop down
./develop exec app bash
./develop run --rm -w /var/www/html app bash