티스토리 뷰

설정정보

  • centos8
  • apache
  • php
  • laravel
  • postgres

        1. Docker for mac 다운로드
          • [Docker for mac Download 바로가기]
        2. 프로젝트 디렉토리 생성
          • path : [path]
          • ex) /Users/honeypigman/Documents/project
        3. Dockerfile 작성
          FROM centos:8
          
          RUN yum -y install glibc-locale-source
          RUN localedef -f UTF-8 -i ko_KR ko_KR.utf8
          ENV LC_ALL ko_KR.utf8
          ENV LANG ko_KR.utf8
          ENV LANGUAGE ko_KR.utf8
           
          ENV TZ=Asia/Seoul
          RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
          RUN	yum update -y
          RUN	yum install -y gcc wget vim net-tools telnet bind-utils unzip cronie gcc gcc-c++ openssl openssl-devel curl zip php-zip npm
           
          # Apache
          RUN yum install -y httpd
           
          # PHP setting
          RUN yum install -y php* php-common php-opcache php-cli php-gd php-curl php-mysqlnd \
              && yum install -y php-json php-mbstring php-dom
          
          RUN mkdir /run/php-fpm
          
          # Git
          RUN yum install -y git
          
          # Setting Conf
          COPY vhost.conf /etc/httpd/conf.d/
          COPY httpd.conf /etc/httpd/conf/
          
          # Composer & Laravel
          RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
              && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
              && php -r "unlink('composer-setup.php');"
          
          RUN	yum remove -y libsodium
          
          # Add User
          RUN useradd laravel
          RUN su - laravel
          RUN composer global require laravel/installer
          RUN ["/bin/bash", "-c", "echo PATH=$PATH:~/.composer/vendor/bin/ >> ~/.bashrc"]
          RUN ["/bin/bash", "-c", "source ~/.bashrc"]
          
          # Laravel Form QueryBuilder for composer require doctrine/dbal:2.*
          #RUN composer require doctrine/dbal:2.*
          
          RUN chmod 755 /home/laravel
          
          RUN su - laravel
          RUN composer create-project --prefer-dist laravel/laravel /home/laravel/[ProjectName]
          RUN chmod -R 777 /home/laravel/[ProjectName]/storage
          
          RUN php-fpm -F -R &
          
          EXPOSE 80
          EXPOSE 443
           
          WORKDIR /home/laravel/
           
          CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]​
        4. vhost.conf 설정
          <VirtualHost *:80> 
              DocumentRoot "/home/laravel/[ProjectName]/public"
              ServerAdmin test@test.com 
              ServerName test.net
          </VirtualHost>
          <Directory "/home/laravel/[ProjectName]/public">
              Options FollowSymLinks
              AllowOverride ALL
              Require all granted 
          </Directory>
        5. Docker Build
          -- Create Docker Image
          docker build -t centos8_apache_php .
        6. Docker Run
          # Basic
          - Container Name : test-was 
          - Docker Image : centos8_apache_php
          docker run -d -p 80:80 --name test-was centos8_apache_php
          
          # Share Directory ( Mount Volumn )
          - Container Name : test-was 
          - Docker Image : centos8_apache_php
          - Mount Directory : [path]:/home/laravel
          docker run -v [path]:/home/laravel -d -p 80:80 --name test-was centos8_apache_php
        7. Php-fpm Run
          php-fpm -F -R
        8. DB::Postgresql Docker Pull & Run
          # Pull
          docker pull centos/postgresql-12-centos8
          
          # Run
          # Basic
          - DB Name : test-db
          docker run -p 5432:5432 --name test-db -e POSTGRES_USER=[set_user] -e POSTGRES_PASSWORD=[set_password] -d postgres
          
          # Share Directory ( Mount Volumn )
          - DB Name : test-db
          docker run -p 5432:5432 --name test-db -e POSTGRES_USER=[set_user] -e POSTGRES_PASSWORD=[set_password] -d -v [local path]:/var/lib/postgresql/data postgres

기존 Windows 개발환경의 이관을 목표로 하였으며, Mac M1에서도 목표로했던 수준의 웹개발 환경구축이 가능했다.


참고자료

 

댓글