Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Laravelを本番環境にデプロイするまで

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for yukure yukure
March 18, 2019

 Laravelを本番環境にデプロイするまで

Avatar for yukure

yukure

March 18, 2019
Tweet

More Decks by yukure

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ • ໊લɿߚྛ ༏ (@yukure3) • ॴଐɿגࣜձࣾ͏ΔΔ • ܦྺɿ৽ଔ̍೥໨ΤϯδχΞ •

    ࠷ۙ΍͍ͬͯΔ͜ͱɿLaravel / Vue.js • ͓఻͑ͨ͜͠ͱɿࠓճͷLT͕ਓੜॳొஃͰ͢…!!
  2. ࣗݾ঺հ • ໊લɿߚྛ ༏ (@yukure3) • ॴଐɿגࣜձࣾ͏ΔΔ • ܦྺɿ৽ଔ̍೥໨ΤϯδχΞ •

    ࠷ۙ΍͍ͬͯΔ͜ͱɿLaravel / Vue.js • ͓఻͑ͨ͜͠ͱɿࠓճͷLT͕ਓੜॳొஃͰ͢…!!
  3. ϩʔΧϧ։ൃ؀ڥ # σΟϨΫτϦ࡞੒ & ͦͷσΟϨΫτϦʹҠಈ $ mkdir project && cd

    project # laradockΛΫϩʔϯ $ git clone https://github.com/Laradock/laradock.git # laravel(࠷৽൛)ΛΠϯετʔϧ $ composer create-project --prefer-dist laravel/laravel src # LaradockσΟϨΫτϦҠಈ & .envΛ࡞੒ $ cd laradock $ cp env-example .env # σΟϨΫτϦߏ଄ project !"" laradock ←ΠϚίίʂʂ #"" src
  4. .env(laradock)ͷमਖ਼ # nginx ͷport & mysqlͷ version มߋ - APP_CODE_PATH_HOST=../

    + APP_CODE_PATH_HOST=../src - NGINX_HOST_HTTP_PORT=80 + NGINX_HOST_HTTP_PORT=8001 - MYSQL_VERSION=latest + MYSQL_VERSION=5.7
  5. .env(laravel)ͷमਖ਼ # ઀ଓઌͷDBมߋ - DB_HOST=127.0.0.1 + DB_HOST=mysql - DB_DATABASE=homestead +

    DB_DATABASE=default - DB_USERNAME=homestead + DB_USERNAME=root - DB_PASSWORD=secret + DB_PASSWORD=root
  6. ϦϞʔτϦϙδτϦ΁push # src΁Ҡಈ cd src # gitϦϙδτϦ࡞੒ git init #

    ઌ΄Ͳ࡞੒ͨ͠ϦϞʔτϦϙδτϦͷ௥Ճ git remote add upstream [email protected]:yukure/laravel-vue.git # first commit ͸͔ΒίϛοτͰʂ git commit --allow-empty -m "first commit!!" # laravelΛόʔδϣϯ؅ཧͷର৅ͱͯ͠௥Ճ git add . # ίϛοτ git commit -m "add: laravel app" # ϦϞʔτϦϙδτϦʹΞοϓϩʔυ git push upstream master
  7. EB CLIͷΠϯετʔϧ # EB CLIͷΠϯετʔϧ brew install awsebcli # EB

    CLI͕Πϯετʔϧ͞Ε͍ͯΔ͔֬ೝ eb --version
  8. # srcσΟϨΫτϦ಺Ͱߦ͍ͬͯͩ͘͞ # ॳظઃఆ(.elasticbeanstalk/config.ymlͷ࡞੒) eb init # ͜Μͳײ͡Ͱ౴͍͖͑ͯ·͢ Select a

    default region 1) us-east-1 : US East (N. Virginia) 2) us-west-1 : US West (N. California) 3) us-west-2 : US West (Oregon) 4) eu-west-1 : EU (Ireland) 5) eu-central-1 : EU (Frankfurt) 6) ap-south-1 : Asia Pacific (Mumbai) 7) ap-southeast-1 : Asia Pacific (Singapore) 8) ap-southeast-2 : Asia Pacific (Sydney) 9) ap-northeast-1 : Asia Pacific (Tokyo) 10) ap-northeast-2 : Asia Pacific (Seoul) 11) sa-east-1 : South America (Sao Paulo) 12) cn-north-1 : China (Beijing) 13) cn-northwest-1 : China (Ningxia) 14) us-east-2 : US East (Ohio) 15) ca-central-1 : Canada (Central) 16) eu-west-2 : EU (London) 17) eu-west-3 : EU (Paris) (default is 3): 9 Select an application to use 1) laravel-vue 2) [ Create new Application ] (default is 1): 1 Select the default environment. You can change this later by typing "eb use [environment_name]". 1) laravel-vue (default is 1): 1 Note: Elastic Beanstalk now supports AWS CodeCommit; a fully-managed source control service. To learn more, see Docs: https://aws.amazon.com/codecommit/ Do you wish to continue with CodeCommit? (y/N) (default is n): n Ϧʔδϣϯͷબ୒ ͲͷΞϓϦέʔγϣϯΛ࢖͏͔ Ͳͷ؀ڥʹσϓϩΠ͢Δ͔ $PEF$PNNJU࢖͏͔
  9. version: 2 defaults: &defaults working_directory: ~/app docker: - image: circleci/php:7.1-node-browsers

    - image: circleci/mysql:5.7 environment: - AWS_REGION: ap-northeast-1 - APP_DEBUG: true - APP_ENV: testing - APP_KEY: base64:cNWYphm1YWH+RGYFLZpn6MBKj/TRiMm46KbuWA8Ei8c= - DB_DATABASE: circle_test - DB_USERNAME: root - MYSQL_ALLOW_EMPTY_PASSWORD: true jobs: build: <<: *defaults steps: - checkout - run: name: install pdo_mysql command: | sudo apt update sudo docker-php-ext-install pdo_mysql sudo docker-php-ext-enable pdo_mysql # Download and cache dependencies - restore_cache: keys: - v1-dependencies-{{ checksum "composer.json" }} # fallback to using the latest cache if no exact match is found - v1-dependencies- - run: composer install -n --prefer-dist - save_cache: paths: - ./vendor key: v1-dependencies-{{ checksum "composer.json" }} # run seeding - run: php artisan migrate - run: php artisan db:seed # run test - run: ./vendor/bin/phpunit deploy: <<: *defaults steps: - checkout - run: name: Install awsebcli command: | sudo apt-get -y -qq update sudo apt-get install python-pip python-dev build-essential sudo pip install awsebcli --upgrade - run: name: eb deploy command: eb deploy laravel-vue workflows: version: 2 build_and_deploy: jobs: - build - deploy: filters: branches: only: - master ίϯςφͷΠϝʔδ΍ ؀ڥม਺Λఆٛ Ϗϧυɾςετͷ࣮ߦ 8PSLqPX δϣϒͷॱ൪ ӡ༻؀ڥ΁σϓϩΠ
  10. .circleci/config.ymlͷઃఆ deploy: <<: *defaults steps: - checkout - run: name:

    Install awsebcli command: | sudo apt-get -y -qq update sudo apt-get install python-pip python-dev build-essential sudo pip install awsebcli --upgrade - run: name: eb deploy command: eb deploy laravel-vue &#ͷ؀ڥ໊ &#$-*Πϯετʔϧ HJUIVC͔ΒίʔυΛνΣοΫΞ΢τ
  11. σϓϩΠͷςετ # ϒϥϯνͷ੾Γସ͑ git checkout -b edit_readme # readme.mdΛฤू͢Δ vim

    readme.md # Laravel/Vue.jsษڧձ#8 Φʔϧελʔζ **Let's Enjoy Laravel!!!!!!!!!!!!!!!!!!!!!!!!!!** readme.md