티스토리 뷰
설정정보
- centos8
- apache
- php
- laravel
- postgres
- Docker for mac 다운로드
- [Docker for mac Download 바로가기]
- 프로젝트 디렉토리 생성
- path : [path]
- ex) /Users/honeypigman/Documents/project
- 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"]
- 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>
- Docker Build
-- Create Docker Image docker build -t centos8_apache_php .
- 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
- Php-fpm Run
php-fpm -F -R
- 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에서도 목표로했던 수준의 웹개발 환경구축이 가능했다.
참고자료
- www.macupdate.com/app/mac/49208/dbeaver
- code.visualstudio.com/download
- hub.docker.com/r/centos/postgresql-12-centos8
- docs.docker.com/docker-for-mac/install/
'프로그래밍 > Docker' 카테고리의 다른 글
Docker 이미지 이름 재설정 방법 (0) | 2021.09.10 |
---|---|
[Docker] Container SSL인증서 - Let`s Encrypt 적용 (0) | 2021.03.24 |
[Docker] container crontab 설정 (0) | 2021.03.24 |
[Docker] 기본 명령어 정리 (0) | 2021.03.21 |
[Docker] CentOS 7 설치 (0) | 2021.03.19 |
댓글