Laradock on Docker of Windows

Laradoc에 의한 Laravel 개발 환경을 Docker of Windows로 구축한다.

Laravel을 사용하기 위해 Laradoc에서 개발 환경을 정리해보십시오.
Docker도 공부중이므로, 탐구하면서 해 본다.

PC 환경



Docker, git이 설치되어 있다고 가정합니다.
  • CPU i5, Memory 8G
  • Windows 10 Pro
  • Docker of Windows
  • git

  • Laradock 개요



    라라벨 의 Docker 개발 환경
    Laradoc 문서

    ※ Laravel에는 Homestead라는 vagrant의 공식 개발 환경이 있다.

    Laradoc에서 지원되는 소프트웨어
  • Database Engines: MySQL - MariaDB - Percona - MongoDB - Neo4j - RethinkDB - MSSQL -
    PostgreSQL - Postgres-PostGIS.
  • Database Management: PhpMyAdmin - Adminer - PgAdmin
  • Cache Engines: Redis - Memcached - Aerospike
  • PHP Servers: NGINX - Apache2 - Caddy
  • PHP Compilers: PHP FPM - HHVM
  • Message Queueing: Beanstalkd - RabbitMQ - PHP Worker
  • Queueing Management: Beanstalkd Console - RabbitMQ Console
  • Random Tools: HAProxy - Certbot - Blackfire - Selenium - Jenkins - ElasticSearch - Kibana Mailhog - Minio - Varnish - Swoole - Laravel Echo…

  • 이것들로부터 필요한 소프트웨어를 선택해, 환경 구축할 수 있다.

    Workspace는 Laravel 설정 등을 수행하는 환경
  • Workspace Image Tools PHP CLI - Composer - Git - Linuxbrew - Node - V8JS - Gulp - SQLite - xDebug - Envoy - Deployer - Vim - Yarn - SOAP - Drush…

  • 절차



    Laradoc의 초기 도입


  • 작업 디렉토리 만들기
  • Laradoc 클론하고 laradoc 에 cd
  • env-example에서 .env 만들기
  • docker-compose에서 workspace를 시작합니다
  • docker-compose ps에서 부팅 상태 확인
  • > git clone https://github.com/laradock/laradock
    Cloning into 'laradock'...
    remote: Counting objects: 5124, done.
    remote: Total 5124 (delta 0), reused 0 (delta 0), pack-reused 5124
    Receiving objects: 100% (5124/5124), 5.41 MiB | 335.00 KiB/s, done.
    Resolving deltas: 100% (2650/2650), done.
    
    > cd laradock
    
    > cp env-example .env
    
    > docker-compose up -d workspace
    Creating network "laradock_default" with the default driver
    Creating network "laradock_frontend" with driver "bridge"
    Creating network "laradock_backend" with driver "bridge"
    Creating laradock_applications_1
    Creating laradock_workspace_1
    
    > docker-compose ps
             Name                Command      State           Ports
    -----------------------------------------------------------------------
    laradock_applications_1   /true           Exit 0
    laradock_workspace_1      /sbin/my_init   Up       0.0.0.0:2222->22/tcp
    
    

    Laravel 프로젝트 만들기


  • workspace에 연결
  • 프로젝트 larapj1 만들기 (프로젝트 이름은 선택 사항) Do not run Composer에 깜짝 놀라지 만 잠시 기다리면 처리가 진행됩니다.
  • workspace를 빠져 나가고 중지합니다.
  • > docker exec -it laradock_workspace_1 bash
    root@493f7944504f:/var/www#
    
    root@493f7944504f:/var/www# composer create-project laravel/laravel larapj1
    Do not run Composer as root/super user! See https://getcomposer.org/root for details
    Installing laravel/laravel (v5.4.23)
      - Installing laravel/laravel (v5.4.23): Downloading (100%)
    Created project in larapj1
    > php -r "file_exists('.env') || copy('.env.example', '.env');"
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Package operations: 59 installs, 0 updates, 0 removals
      - Installing symfony/css-selector (v3.3.2): Downloading (100%)
      - Installing tijsverkoyen/css-to-inline-styles (2.2.0): Downloading (100%)
      - Installing symfony/polyfill-mbstring (v1.4.0): Downloading (100%)
      - Installing symfony/var-dumper (v3.3.2): Downloading (100%)
      - Installing jakub-onderka/php-console-color (0.1): Downloading (100%)
      - Installing jakub-onderka/php-console-highlighter (v0.3.2): Downloading (100%)
      - Installing dnoegel/php-xdg-base-dir (0.1): Downloading (100%)
    ...
    
    Writing lock file
    Generating autoload files
    > Illuminate\Foundation\ComposerScripts::postUpdate
    > php artisan optimize
    Generating optimized class loader
    The compiled services file has been removed.
    > php artisan key:generate
    Application key [base64:VwRbtlHayxyJ3b8sIzZfHXRH6XikH/E8bNihDa/CiLk=] set successfully.
    root@493f7944504f:/var/www#exit
    exit
    > docker-compose stop
    Stopping laradock_workspace_1 ... done
    >
    
  • docker-compose.yml에 만든 프로젝트 경로를 반영합니다

  • docker-compose.yml
    version: '2'
    
    services:
    
    ### Applications Code Container #############################
    
        applications:
          image: tianon/true
          volumes:
            - ../larapj1:/var/www
    
  • nginx, mysql 시작
  • > docker-compose up -d nginx mysql
    Creating network "laradock_default" with the default driver
    Creating network "laradock_frontend" with driver "bridge"
    Creating network "laradock_backend" with driver "bridge"
    Creating laradock_mysql_1 ...
    Creating laradock_applications_1 ...
    Creating laradock_mysql_1
    Creating laradock_applications_1 ... done
    Creating laradock_workspace_1 ...
    Creating laradock_workspace_1 ... done
    Creating laradock_php-fpm_1 ...
    Creating laradock_php-fpm_1 ... done
    Creating laradock_nginx_1 ...
    Creating laradock_nginx_1 ... done
    
    > docker-compose ps
             Name                        Command              State                     Ports
    -----------------------------------------------------------------------------------------------------------
    laradock_applications_1   /true                           Exit 0
    laradock_mysql_1          docker-entrypoint.sh mysqld     Up       0.0.0.0:3306->3306/tcp
    laradock_nginx_1          nginx                           Up       0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
    laradock_php-fpm_1        docker-php-entrypoint php-fpm   Up       9000/tcp
    laradock_workspace_1      /sbin/my_init                   Up       0.0.0.0:2222->22/tcp
    
  • Laravel 화면 확인 http://localhost


  • 정지
  • > docker-compose  down
    Stopping laradock_nginx_1 ... done
    Stopping laradock_php-fpm_1 ... done
    Stopping laradock_workspace_1 ... done
    Stopping laradock_mysql_1 ... done
    Removing laradock_nginx_1 ... done
    Removing laradock_php-fpm_1 ... done
    Removing laradock_workspace_1 ... done
    Removing laradock_mysql_1 ... done
    Removing laradock_applications_1 ... done
    Removing network laradock_default
    Removing network laradock_frontend
    Removing network laradock_backend
    
  • apache2, maiadb 시작
  • > docker-compose up -d apache2 mariadb
    Creating laradock_applications_1 ...
    Creating laradock_mariadb_1 ...
    Creating laradock_mariadb_1
    Creating laradock_applications_1 ... done
    Creating laradock_mariadb_1 ... done
    Creating laradock_workspace_1 ... done
    Creating laradock_php-fpm_1 ...
    Creating laradock_php-fpm_1 ... done
    Creating laradock_apache2_1 ...
    Creating laradock_apache2_1 ... done
    
  • Laravel 화면 확인
    웹 서버가 다르더라도 문제없이 Laravel 화면이 표시됩니다.

  • phpmyadmin 시작



    필요할 때 phpmyadmin을 추가로 시작할 수 있습니다.
    > docker-compose ps
             Name                        Command              State                     Ports
    -----------------------------------------------------------------------------------------------------------
    laradock_applications_1   /true                           Exit 0
    laradock_mysql_1          docker-entrypoint.sh mysqld     Up       0.0.0.0:3306->3306/tcp
    laradock_nginx_1          nginx                           Up       0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
    laradock_php-fpm_1        docker-php-entrypoint php-fpm   Up       9000/tcp
    laradock_workspace_1      /sbin/my_init                   Up       0.0.0.0:2222->22/tcp
    
    > docker-compose up -d phpmyadmin
    laradock_mysql_1 is up-to-date
    Creating laradock_phpmyadmin_1 ...
    Creating laradock_phpmyadmin_1 ... done
    
    > docker-compose ps
             Name                        Command              State                     Ports
    -----------------------------------------------------------------------------------------------------------
    laradock_applications_1   /true                           Exit 0
    laradock_mysql_1          docker-entrypoint.sh mysqld     Up       0.0.0.0:3306->3306/tcp
    laradock_nginx_1          nginx                           Up       0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
    laradock_php-fpm_1        docker-php-entrypoint php-fpm   Up       9000/tcp
    laradock_phpmyadmin_1     /run.sh phpmyadmin              Up       0.0.0.0:8080->80/tcp
    laradock_workspace_1      /sbin/my_init                   Up       0.0.0.0:2222->22/tcp
    

    phpmyadmin URL
    http://localhost-8080.com/

    좋은 웹페이지 즐겨찾기