This is a simple Laravel command line application demonstrating using Docker and Docker Compose for PHP application development, continuous integration, and deployment through the Codeship Pro platform.
For convenience, I have wrapped a number of common docker commands in npm scripts. For more details, see the package.json file.
npm run -s app:upStarts up the application and database using Docker Compose.npm run -s app:restartRestarts the application making any code changes take effect.npm run -s app:downBrings down the application and database.npm run -s app:testRuns the test suite.*npm run -s artisan -- ARTISAN:COMMANDWrapper to run artisan commands.*npm run -s artisan -- item:updateUpdate the next item'schecked_atdate.npm run -s composer:installInstall PHP packages via composer.npm run -s composer:updateUpdate PHP packages via composer.npm run -s composer:dumpWrapper for composerdump-autoloadcommand.
* Note: The app must be running in order to run this command.
In order to run this project locally for development, uncomment these lines in the docker-compose file that mount the code as a volume:
app:
build: .
links:
- database
env_file:
- .env
command: cron -f
# Uncomment these lines:
volumes:
- ./:/appThis will ensure that any updates you make take effect immediately in the application container.
Run the composer install command:
$ npm run -s composer:installNow, copy .env.example to .env and customize with your own variables and keys.
Next, run the npm command to bring up the docker containers:
$ npm run -s app:upIf it's your first time running this app, set up the database:
$ npm run -s db:create # Creates the database
$ npm run -s db:migrate # Runs the migrations
$ npm run -s db:seed # Seeds the databaseNow you can run the app's primary artisan command:
$ npm run -s artisan -- item:updateTo bring the containers down when you're finished:
$ npm run -s app:downOnce the app is set up and running, you can run the acceptance test:
$ npm run -s app:testThis runs phpunit from within the running application container.
If you have Codeship's Jet installed, you can run tests from Jet as well.
First, bring the application down (if it's running):
$ npm run -s app:downGenerate an AES encryption key:
$ jet generateEncrypt your .env files:
$ jet encrypt .env .env.encrypted && jet encrypt deployer/.env deployer/.env.encryptedBuild the containers, run the tests, and deploy the latest on the master branch:
$ jet stepsThis project was built to use Codeship's Docker continuous integration platform.
-
Copy your Codeship AES key into a file called
codeship.aesat the root of this project. -
Make sure your
deployer/.envfile is filled out with your server information and private rsa key (with no line breaks). -
Encrypt your .env files:
$ jet encrypt .env .env.encrypted && jet encrypt deployer/.env deployer/.env.encrypted -
Push your code to a repository that is attached to a Codeship Pro CI instance.
This should run your tests and deploy your code to the server specified in deployer/.env
This is open-sourced software licensed under the MIT license.