Created
June 12, 2017 13:21
-
-
Save madsleejensen/1f1a7a845424c314d7c0449019baf22b to your computer and use it in GitHub Desktop.
circleci docker-compose laravel example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
machine: | |
pre: | |
- curl -sSL https://s3.amazonaws.com/circle-downloads/install-circleci-docker.sh | bash -s -- 1.10.0 | |
- sudo curl -L -o /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` | |
- sudo chmod +x /usr/local/bin/docker-compose | |
services: | |
- docker | |
dependencies: | |
override: | |
# generate a .env file by interpolating the template (.env.example) with environment variables (defined in circleci) | |
- >- | |
sed | |
-e "s|\(AWS_ACCESS_KEY_ID\)\s*.*|\1=$AWS_ACCESS_KEY_ID|g" | |
-e "s|\(AWS_SECRET_ACCESS_KEY\)\s*.*|\1=$AWS_SECRET_ACCESS_KEY|g" | |
-e "s|\(FACEBOOK_APP_ID\)\s*.*|\1=$FACEBOOK_APP_ID|g" | |
-e "s|\(FACEBOOK_APP_SECRET\)\s*.*|\1=$FACEBOOK_APP_SECRET|g" | |
-e "s|\(STRIPE_API_KEY\)\s*.*|\1=$STRIPE_API_KEY|g" | |
-e "s|\(MAILGUN_SECRET\)\s*.*|\1=$MAILGUN_SECRET|g" | |
.env.example > .env | |
# workaround | |
# when building `web` with `docker-compose` something doesnt work when using mounted volumnes. | |
# docker-compose builds fine, but when finished on the HOST filesystem no vendor/ was created (its like mounted volumnes doesnt work at all) | |
# | |
# so instead we explicitly install the composer dependencies by NOT using `docker-compose` which works fine. | |
- docker run -it --workdir /usr/src/app -v $(pwd):/usr/src/app richarvey/nginx-php-fpm:1.2.0 bash -c "composer install" | |
- docker-compose up -d | |
database: | |
override: | |
- sleep 5 # wierd behavior, some times we receive "Connection refused" because docker-compose has not yet started database. | |
- docker-compose run web bash -c "php artisan migrate --seed" | |
test: | |
override: | |
- docker-compose run web vendor/bin/phpunit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment