-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 28337bb
Showing
239 changed files
with
184,548 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# PHP CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-php/ for more details | ||
# | ||
version: 2 | ||
jobs: | ||
test: | ||
docker: | ||
# Specify the version you desire here | ||
- image: circleci/php:7.3-fpm | ||
- image: circleci/mysql:latest | ||
command: [--default-authentication-plugin=mysql_native_password] | ||
environment: | ||
MYSQL_ROOT_PASSWORD: rootPass | ||
MYSQL_USER: user # need to be same with "DB_USERNAME" of .env.testing | ||
MYSQL_PASSWORD: password # need to be same with "DB_PASSWORD" of .env.testing | ||
MYSQL_DATABASE: test_laravel # need to be same with "DB_DATABASE" of .env.testing | ||
- image: rnwood/smtp4dev:linux-amd64-v3 | ||
|
||
working_directory: ~/laravel/laravel | ||
|
||
steps: | ||
- checkout: | ||
path: ~/laravel | ||
- run: sudo apt-get update -y | ||
- run: sudo apt-get install -y libpng-dev libjpeg-dev zip unzip git | ||
- run: sudo rm -rf /var/lib/apt/lists/* | ||
- run: sudo docker-php-ext-install zip | ||
- run: sudo docker-php-ext-configure gd --with-jpeg-dir=/usr/lib/x86_64-linux-gnu/ | ||
- run: sudo docker-php-ext-install pdo pdo_mysql gd mbstring zip | ||
- run: sudo composer self-update | ||
|
||
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
# "composer.lock" can be used if it is committed to the repo | ||
- v1-dependencies-{{ checksum "composer.json" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
|
||
- run: | ||
name: "Install Dependencies" | ||
command: composer install -n --prefer-dist | ||
|
||
- save_cache: | ||
key: v1-dependencies-{{ checksum "composer.json" }} | ||
paths: | ||
- ./vendor | ||
|
||
# prepare the database | ||
- run: | ||
name: "Create Environment file and generate app key" | ||
command: | | ||
mv .env.circleci .env.testing | ||
php artisan key:generate --env=testing | ||
php artisan config:clear | ||
php artisan cache:clear | ||
- run: | ||
name: "Create database and run migration" | ||
command: | | ||
php artisan migrate:refresh --seed --env=testing | ||
# run tests with phpunit | ||
- run: | ||
name: "Run Tests" | ||
command: phpdbg -qrr vendor/bin/phpunit --coverage-html build/coverage-report | ||
|
||
# reset DataBase | ||
- run: | ||
name: "Reset Database to initial state" | ||
command: php artisan migrate:reset --env=testing | ||
|
||
- store_artifacts: | ||
path: build/coverage-report | ||
|
||
build_and_push: | ||
docker: | ||
- image: docker:18.06.1-ce-git | ||
environment: | ||
DOCKER_IMAGE: php-fpm | ||
APP: laravel-vue | ||
AWS_REGION: ap-southeast-1 | ||
working_directory: ~/tjm | ||
steps: | ||
- checkout | ||
- setup_remote_docker: | ||
version: 18.06.0-ce | ||
# docker_layer_caching: true | ||
- run: | ||
name: Install requirements | ||
command: | | ||
apk add --no-cache py-pip bash | ||
pip install awscli | ||
- run: | ||
name: docker build | ||
command: | | ||
docker build -t $DOCKER_IMAGE --no-cache laravel/. | ||
- run: | ||
name: push builds | ||
shell: /bin/bash | ||
command: | | ||
set -e | ||
eval $(aws --region $AWS_REGION ecr get-login --no-include-email) | ||
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --output text | awk '{print $1}') | ||
export SHA1=$(echo ${CIRCLE_SHA1} | cut -c1-7) | ||
docker images | ||
docker tag $DOCKER_IMAGE:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$APP:$SHA1 | ||
docker tag $DOCKER_IMAGE:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$APP:$CIRCLE_BRANCH | ||
time docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$APP:$SHA1 | ||
time docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$APP:$CIRCLE_BRANCH | ||
deploy: | ||
docker: | ||
- image: circleci/python:3.7 | ||
steps: | ||
- checkout | ||
- run: | ||
name: Install deploy tools | ||
command: | | ||
sudo pip install awsebcli==3.14.6 | ||
wget http://bit.ly/eb_deploy_and_notify_sh -O ~/eb_deploy_and_notify.sh | ||
chmod +x ~/eb_deploy_and_notify.sh | ||
- run: | ||
name: Deploy! | ||
shell: /bin/bash | ||
command: | | ||
set -e | ||
eb --version | ||
export EB_ENV=`eb list | grep '*' | awk '{print $2}'` | ||
export SHA1=$(echo ${CIRCLE_SHA1} | cut -c1-7) | ||
echo "${CIRCLE_BRANCH}" ; echo "${EB_ENV}" ; echo "${SHA1}" | ||
cd laravel | ||
sed -i -e "s/changeme/$SHA1/" Dockerrun.aws.json | ||
git add Dockerrun.aws.json | ||
git rm Dockerfile | ||
~/eb_deploy_and_notify.sh ${EB_ENV} --staged | ||
no_output_timeout: 15m | ||
|
||
workflows: | ||
version: 2 | ||
test-build-deploy: | ||
jobs: | ||
- test | ||
- build_and_push: | ||
requires: | ||
- test | ||
filters: | ||
branches: | ||
only: | ||
- develop | ||
- master | ||
- deploy: | ||
requires: | ||
- build_and_push | ||
filters: | ||
branches: | ||
only: | ||
- develop | ||
- master |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Listen for XDebug", | ||
"type": "php", | ||
"request": "launch", | ||
"port": 9000, | ||
"pathMappings": { | ||
"/var/www/html/": "${workspaceRoot}/laravel" | ||
}, | ||
"ignore": [ | ||
"**/vendor/**/*.php" | ||
] | ||
}, | ||
{ | ||
"name": "Launch currently open script", | ||
"type": "php", | ||
"request": "launch", | ||
"program": "${file}", | ||
"cwd": "${fileDirname}", | ||
"port": 9000 | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Laravel Vue Circleci AWS Elastic Beanstalk | ||
|
||
## Prerequisites | ||
1. install `docker` | ||
1. install `docker-compose` | ||
|
||
## Local Project Setup | ||
1. start `docker-compose` | ||
``` | ||
$ docker-compose up -d | ||
``` | ||
1. create `.env` file | ||
``` | ||
$ cp laravel/.env.example laravel/.env | ||
``` | ||
1. install composer | ||
``` | ||
$ docker-compose exec php-fpm composer install | ||
``` | ||
1. db migrate and seed | ||
``` | ||
$ docker-compose exec php-fpm php artisan migrate --seed | ||
``` | ||
1. passport install | ||
``` | ||
$ docker-compose exec php-fpm php artisan passport:install | ||
``` | ||
1. link to storage | ||
``` | ||
$ docker-compose exec php-fpm php artisan storage:link | ||
``` | ||
1. give root permission to storage`(Only for linux user)` | ||
``` | ||
$ docker-compose exec php-fpm sh | ||
$ cd storage && chown -R www-data:www-data * | ||
$ exit | ||
``` | ||
1. watch vue changes | ||
``` | ||
$ docker-compose exec php-fpm yarn install | ||
$ docker-compose exec php-fpm yarn watch | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
version: "3.7" | ||
|
||
services: | ||
nginx: | ||
image: nginx:latest | ||
ports: | ||
- 8000:80 # To change host access port number | ||
volumes: | ||
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf | ||
- ./laravel:/var/www/html # To change project folder name | ||
depends_on: | ||
- php-fpm | ||
|
||
php-fpm: | ||
build: | ||
context: ./php-fpm | ||
target: dev | ||
working_dir: /var/www/html | ||
volumes: | ||
- ./php-fpm/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini | ||
- ./laravel:/var/www/html # To change project folder name | ||
depends_on: | ||
- mysql | ||
- phpmyadmin | ||
|
||
mysql: | ||
image: mysql:latest | ||
ports: | ||
- 3306:3306 # To change mysql port number | ||
environment: | ||
MYSQL_ROOT_PASSWORD: rootPass | ||
MYSQL_USER: user # To change database user | ||
MYSQL_PASSWORD: password # To change database user password | ||
MYSQL_DATABASE: laravel # To change database name | ||
volumes: | ||
- ./mysql/custom.cnf:/etc/mysql/conf.d/custom.cnf | ||
- db-data:/var/lib/mysql | ||
|
||
phpmyadmin: # This is for mysql GUI view in windows | ||
image: phpmyadmin/phpmyadmin | ||
links: | ||
- mysql | ||
environment: | ||
PMA_HOST: mysql | ||
PMA_PORT: 3306 | ||
PMA_ARBITRARY: 1 | ||
restart: always | ||
ports: | ||
- 8183:80 | ||
|
||
volumes: | ||
db-data: |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Resources: | ||
AWSEBAutoScalingGroup: | ||
Type: "AWS::AutoScaling::AutoScalingGroup" | ||
Properties: | ||
HealthCheckType: "ELB" | ||
HealthCheckGracePeriod: 900 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# EB configs | ||
|
||
commands: | ||
01_timezone: | ||
command: ln -nsf /usr/share/zoneinfo/Japan /etc/localtime | ||
02_swapon: | ||
command: | | ||
if (curl -s http://169.254.169.254/latest/meta-data/instance-type | grep -E "\.micro$" > /dev/null) | ||
then | ||
SWAPFILE=/tmp/swap.img | ||
test -e $SWAPFILE && exit 0 | ||
MEMSIZE=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'` | ||
if [ $MEMSIZE -lt 2097152 ]; then | ||
SIZE=$((MEMSIZE * 1))k | ||
elif [ $MEMSIZE -lt 8388608 ]; then | ||
SIZE=${MEMSIZE}k | ||
elif [ $MEMSIZE -lt 67108864 ]; then | ||
SIZE=$((MEMSIZE / 2))k | ||
else | ||
SIZE=4194304k | ||
fi | ||
fallocate -l $SIZE $SWAPFILE && mkswap $SWAPFILE && chmod 0600 $SWAPFILE && swapon $SWAPFILE | ||
fi | ||
03_sysctl: | ||
command: | | ||
sysctl -w net.core.somaxconn=8192 | ||
container_commands: | ||
01_symlink_www: | ||
command: | | ||
ln -sf /var/app/current /var/www | ||
files: | ||
"/etc/nginx/conf.d/proxy.conf": | ||
mode: "000644" | ||
owner: root | ||
group: root | ||
content: | | ||
client_max_body_size 650M; | ||
"/etc/nginx/sites-available/elasticbeanstalk-nginx-docker-proxy.conf": | ||
mode: "000644" | ||
owner: root | ||
group: root | ||
content: | | ||
map $http_upgrade $connection_upgrade { | ||
default "upgrade"; | ||
"" ""; | ||
} | ||
|
||
server { | ||
listen 80; | ||
|
||
gzip on; | ||
gzip_comp_level 4; | ||
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; | ||
|
||
access_log /var/log/nginx/access.log; | ||
|
||
index index.php index.html; | ||
root /var/www/public; | ||
client_max_body_size 650m; | ||
|
||
location / { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
|
||
#proxy_pass http://docker; | ||
#proxy_http_version 1.1; | ||
|
||
#proxy_set_header Connection $connection_upgrade; | ||
#proxy_set_header Upgrade $http_upgrade; | ||
#proxy_set_header Host $host; | ||
#proxy_set_header X-Real-IP $remote_addr; | ||
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
} | ||
|
||
location ~ \.php$ { | ||
root /var/www/html/public; | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
fastcgi_pass docker; | ||
fastcgi_index index.php; | ||
include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
} | ||
|
||
if ($http_user_agent !~* '^ELB-HealthChecker\/.*$') { | ||
set $r 1; | ||
} | ||
|
||
if ($http_x_forwarded_proto = 'http') { | ||
set $r "${r}1"; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# EB configs | ||
|
||
packages: | ||
yum: | ||
git: [] |
Oops, something went wrong.