Skip to content

Commit e9d65f3

Browse files
committed
docker-apache-php-mysql-laravel environment done
1 parent e5dba19 commit e9d65f3

File tree

112 files changed

+12996
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+12996
-0
lines changed

.circleci/config.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 2
2+
jobs:
3+
build:
4+
working_directory: ~/laravel
5+
machine: true
6+
branches:
7+
ignore:
8+
- master
9+
- develop
10+
steps:
11+
- checkout
12+
13+
- run:
14+
name: Start container and verify it's working
15+
command: |
16+
make start-ci
17+
18+
- run:
19+
name: Wait for DB container is running and initialize DB
20+
command: |
21+
make wait-for-db
22+
make drop-migrate
23+
make migrate
24+
make seed
25+
26+
- run:
27+
name: Run unit/functional tests
28+
command: |
29+
make phpunit
30+
31+
- store_artifacts:
32+
path: reports
33+
34+
- store_test_results:
35+
path: reports

.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.dockerignore
2+
docker-compose.yml
3+
docker-compose-ci.yml
4+
docker-compose-prod.yml
5+
Makefile
6+
/.git*
7+
/.idea*
8+
storage/mysql-data
9+
vendor/
10+
bootstrap/cache
11+
!bootstrap/cache/.gitignore

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.yml]
15+
indent_size = 2

.env.example

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
9+
DB_CONNECTION=mysql
10+
DB_HOST=127.0.0.1
11+
DB_PORT=3306
12+
DB_DATABASE=homestead
13+
DB_USERNAME=homestead
14+
DB_PASSWORD=secret
15+
16+
BROADCAST_DRIVER=log
17+
CACHE_DRIVER=file
18+
QUEUE_CONNECTION=sync
19+
SESSION_DRIVER=file
20+
SESSION_LIFETIME=120
21+
22+
REDIS_HOST=127.0.0.1
23+
REDIS_PASSWORD=null
24+
REDIS_PORT=6379
25+
26+
MAIL_DRIVER=smtp
27+
MAIL_HOST=smtp.mailtrap.io
28+
MAIL_PORT=2525
29+
MAIL_USERNAME=null
30+
MAIL_PASSWORD=null
31+
MAIL_ENCRYPTION=null
32+
33+
PUSHER_APP_ID=
34+
PUSHER_APP_KEY=
35+
PUSHER_APP_SECRET=
36+
PUSHER_APP_CLUSTER=mt1
37+
38+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
39+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.env.local

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=base64:KgeWah2LwOk5HLjCYuIZjaQQwX59ASqUjCKZMD6H4Ew=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
9+
DB_CONNECTION=mysql
10+
DB_HOST=mysql
11+
DB_PORT=3306
12+
DB_DATABASE=laravel
13+
DB_USERNAME=root
14+
DB_PASSWORD=secret
15+
16+
BROADCAST_DRIVER=log
17+
CACHE_DRIVER=file
18+
QUEUE_CONNECTION=sync
19+
SESSION_DRIVER=file
20+
SESSION_LIFETIME=120
21+
22+
REDIS_HOST=127.0.0.1
23+
REDIS_PASSWORD=null
24+
REDIS_PORT=6379
25+
26+
MAIL_DRIVER=smtp
27+
MAIL_HOST=smtp.mailtrap.io
28+
MAIL_PORT=2525
29+
MAIL_USERNAME=null
30+
MAIL_PASSWORD=null
31+
MAIL_ENCRYPTION=null
32+
33+
PUSHER_APP_ID=
34+
PUSHER_APP_KEY=
35+
PUSHER_APP_SECRET=
36+
PUSHER_APP_CLUSTER=mt1
37+
38+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
39+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.env.prod

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
APP_NAME=Laravel
2+
APP_ENV=production
3+
APP_KEY=
4+
APP_DEBUG=false
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
9+
DB_CONNECTION=mysql
10+
DB_HOST=mysql
11+
DB_PORT=3306
12+
DB_DATABASE=laravel
13+
DB_USERNAME=root
14+
DB_PASSWORD=secret
15+
16+
BROADCAST_DRIVER=log
17+
CACHE_DRIVER=file
18+
QUEUE_CONNECTION=sync
19+
SESSION_DRIVER=file
20+
SESSION_LIFETIME=120
21+
22+
REDIS_HOST=127.0.0.1
23+
REDIS_PASSWORD=null
24+
REDIS_PORT=6379
25+
26+
MAIL_DRIVER=smtp
27+
MAIL_HOST=smtp.mailtrap.io
28+
MAIL_PORT=2525
29+
MAIL_USERNAME=null
30+
MAIL_PASSWORD=null
31+
MAIL_ENCRYPTION=null
32+
33+
PUSHER_APP_ID=
34+
PUSHER_APP_KEY=
35+
PUSHER_APP_SECRET=
36+
PUSHER_APP_CLUSTER=mt1
37+
38+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
39+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.env.testing

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
APP_NAME=Laravel
2+
APP_ENV=testing
3+
APP_KEY=base64:KgeWah2LwOk5HLjCYuIZjaQQwX59ASqUjCKZMD6H4Ew=
4+
APP_DEBUG=false
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
9+
DB_CONNECTION=mysql
10+
DB_HOST=mysql
11+
DB_PORT=3306
12+
DB_DATABASE=laravel_testing
13+
DB_USERNAME=root
14+
DB_PASSWORD=secret
15+
16+
BROADCAST_DRIVER=log
17+
CACHE_DRIVER=file
18+
QUEUE_CONNECTION=sync
19+
SESSION_DRIVER=file
20+
SESSION_LIFETIME=120
21+
22+
REDIS_HOST=127.0.0.1
23+
REDIS_PASSWORD=null
24+
REDIS_PORT=6379
25+
26+
MAIL_DRIVER=smtp
27+
MAIL_HOST=smtp.mailtrap.io
28+
MAIL_PORT=2525
29+
MAIL_USERNAME=null
30+
MAIL_PASSWORD=null
31+
MAIL_ENCRYPTION=null
32+
33+
PUSHER_APP_ID=
34+
PUSHER_APP_KEY=
35+
PUSHER_APP_SECRET=
36+
PUSHER_APP_CLUSTER=mt1
37+
38+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
39+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/.idea
2+
/.vscode
3+
/.vagrant
4+
/node_modules
5+
/public/hot
6+
/public/storage
7+
/storage/*.key
8+
/storage/mysql-data/
9+
/vendor
10+
Homestead.yaml
11+
Homestead.json
12+
.env
13+
_ide_helper.php
14+
.phpstorm.meta.php
15+
_ide_helper_models.php
16+
reports/*
17+
!reports/.gitkeep
18+
npm-debug.log
19+
yarn-error.log
20+
.phpunit.result.cache

Makefile

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
ENV=local
2+
dir=${CURDIR}
3+
project=-p laravel
4+
service=laravel:latest
5+
6+
start:
7+
@docker-compose -f docker-compose.yml $(project) up -d
8+
9+
start-ci:
10+
@docker-compose -f docker-compose-ci.yml $(project) up -d
11+
12+
start-prod:
13+
@docker-compose -f docker-compose-prod.yml $(project) up -d
14+
15+
stop:
16+
@docker-compose -f docker-compose.yml $(project) down
17+
18+
stop-ci:
19+
@docker-compose -f docker-compose-ci.yml $(project) down
20+
21+
stop-prod:
22+
@docker-compose -f docker-compose-prod.yml $(project) down
23+
24+
restart: stop start
25+
restart-ci: stop-ci start-ci
26+
restart-prod: stop-prod start-prod
27+
28+
env-local:
29+
cp ./.env.local ./.env
30+
31+
env-prod:
32+
cp ./.env.prod ./.env
33+
34+
ssh:
35+
@docker-compose $(project) exec laravel bash
36+
37+
exec:
38+
@docker-compose $(project) exec laravel $$cmd
39+
40+
clean:
41+
rm -rf $(dir)/reports
42+
43+
prepare:
44+
mkdir $(dir)/reports
45+
mkdir $(dir)/reports/coverage
46+
47+
wait-for-db:
48+
@make exec cmd="php artisan db:wait"
49+
50+
composer-install-prod:
51+
@make exec cmd="composer install --no-dev"
52+
53+
composer-install:
54+
@make exec cmd="composer install"
55+
56+
composer-update:
57+
@make exec cmd="composer update"
58+
59+
info:
60+
@make exec cmd="php artisan --version"
61+
@make exec cmd="php --version"
62+
63+
drop-migrate:
64+
@make exec cmd="php artisan migrate:fresh"
65+
@make exec cmd="php artisan migrate:fresh --env=testing"
66+
67+
migrate:
68+
@make exec cmd="php artisan migrate --force"
69+
@make exec cmd="php artisan migrate --force --env=testing"
70+
71+
seed:
72+
@make exec cmd="php artisan db:seed --force"
73+
74+
phpunit:
75+
@make exec cmd="vendor/bin/phpunit -c phpunit.xml --log-junit reports/phpunit.xml --coverage-html reports/coverage --coverage-clover reports/coverage.xml"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
namespace App\Console\Commands;
3+
4+
use DB;
5+
use Illuminate\Console\Command;
6+
use Illuminate\Database\QueryException;
7+
8+
class DbWaitDatabase extends Command
9+
{
10+
const WAIT_SLEEP_TIME = 2;
11+
12+
/**
13+
* The name and signature of the console command.
14+
*
15+
* @var string
16+
*/
17+
protected $signature = 'db:wait';
18+
19+
/**
20+
* The console command description.
21+
*
22+
* @var string
23+
*/
24+
protected $description = 'Waits for database availability.';
25+
26+
/**
27+
* Execute the console command.
28+
*
29+
* @param DB $db
30+
*
31+
* @return integer
32+
*/
33+
public function handle(DB $db)
34+
{
35+
for ($i = 0; $i < 60; $i += self::WAIT_SLEEP_TIME) {
36+
try {
37+
$db::select('SHOW TABLES');
38+
return 0;
39+
} catch (QueryException $e) {
40+
sleep(self::WAIT_SLEEP_TIME);
41+
continue;
42+
}
43+
}
44+
45+
return 1;
46+
}
47+
}

0 commit comments

Comments
 (0)