├── .env.example ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── conf ├── .gitignore ├── crontab │ └── crontab.conf ├── mysql │ └── conf.d │ │ └── bind_0.cnf ├── nginx │ └── sites-enabled │ │ └── default.conf ├── redis │ └── redis.conf └── supervisor │ ├── conf.d │ ├── crontab.conf │ ├── laravel.conf │ ├── mysql.conf │ ├── nginx.conf │ ├── phpfpm.conf │ └── redis.conf │ └── supervisord.conf ├── docker-compose.yml ├── docs └── tr_TR │ └── GENERAL.md ├── opt ├── installer │ ├── 3rd-installer.sh │ ├── mysql-installer.sh │ ├── nginx-installer.sh │ ├── phpfpm-installer.sh │ └── redis-installer.sh ├── program │ └── start-mysql.sh └── start.sh └── storage └── .gitignore /.env.example: -------------------------------------------------------------------------------- 1 | ## PROJECT ## 2 | COMPOSE_PROJECT_NAME=kodhub 3 | PHP_IDE_CONFIG=phpstorm 4 | 5 | ## PORTS ## 6 | NGINX_PORT=1100 7 | SUPERVISOR_PORT=1101 8 | MYSQL_PORT=1102 9 | RABBITMQ_PORT=1103 10 | REDIS_PORT=1104 11 | PHPFPM_PORT=1105 12 | 13 | ## IPS ## 14 | IP_ADDRESS= 15 | 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | ./storage 3 | !./storage/.gitignore 4 | htdocs 5 | .env 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | USER root 3 | 4 | ## UPDATE OS ## 5 | RUN apt update 6 | 7 | # COPY OPT FOLDER 8 | RUN mkdir -p /opt/docker/system 9 | COPY ./opt /opt/docker/system 10 | RUN chmod -R 755 /opt/docker/* 11 | 12 | # COPY CONF FOLDER 13 | COPY ./conf /etc 14 | 15 | ## INSTALL NGINX 16 | RUN /opt/docker/system/installer/nginx-installer.sh 17 | 18 | ## INSTALL 3RD APPS 19 | RUN /opt/docker/system/installer/3rd-installer.sh 20 | 21 | ## PHP INSTALLLER AREA ## 22 | RUN /opt/docker/system/installer/phpfpm-installer.sh 23 | 24 | ## MYSQL INSTALLER ## 25 | RUN /opt/docker/system/installer/mysql-installer.sh 26 | 27 | ## REDIS INSTALLER ## 28 | RUN /opt/docker/system/installer/redis-installer.sh 29 | 30 | ## CHMOD 31 | RUN usermod -u 1000 www-data 32 | 33 | ## RUN SUPERVISORD 34 | ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"] 35 | 36 | ## SET WORKDIR PATH 37 | WORKDIR /var/www 38 | 39 | EXPOSE 3306 9000 80 6379 40 | 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Kodhub 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel Dockerized 2 | ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/kodhub/laravel-dockerized?include_prereleases) 3 | ![GitHub issues](https://img.shields.io/github/issues-raw/kodhub/laravel-dockerized) 4 | ![GitHub closed issues](https://img.shields.io/github/issues-closed-raw/kodhub/laravel-dockerized?color=009fe1) 5 | ![GitHub All Releases](https://img.shields.io/github/downloads/kodhub/laravel-dockerized/total?) 6 | 7 | Laravel easy docker environment. 8 | 9 | [for Magento2](https://github.com/kodhub/magento2-dockerized) 10 | 11 | ### Support 12 | * nginx 13 | * php-fpm ( v7.2 ) 14 | * mysql ( v5.7 ) 15 | * redis 16 | * crontab 17 | * supervisor 18 | 19 | ### Install on Your Laravel Project 20 | 21 | Write the following code to the directory where your project folder is located on the terminal. 22 | 23 | 1- `git clone git@github.com:kodhub/laravel-dockerized.git .docker` 24 | 25 | 2- `docker-compose up -d --build` 26 | 27 | 3- `docker exec -it bash` 28 | 29 | 4- Your project install steps 30 | 31 | 32 | ### Documentation 33 | 34 | [Türkçe dökümana git ->](https://github.com/kodhub/laravel-dockerized/blob/develop/docs/tr_TR/GENERAL.md) 35 | -------------------------------------------------------------------------------- /conf/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodhub/laravel-dockerized/3864d20f0e38821eedc54d355510707787bf0ed8/conf/.gitignore -------------------------------------------------------------------------------- /conf/crontab/crontab.conf: -------------------------------------------------------------------------------- 1 | ## FIRST LINE NON DELETE!! ## 2 | * * * * * php /var/www/artisan schedule:run >> /var/log/schedule-run.log 3 | -------------------------------------------------------------------------------- /conf/mysql/conf.d/bind_0.cnf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | bind-address=0.0.0.0 3 | -------------------------------------------------------------------------------- /conf/nginx/sites-enabled/default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 0.0.0.0:80; 3 | listen [::]:80; 4 | 5 | # For https 6 | # listen 443 ssl; 7 | # listen [::]:443 ssl ipv6only=on; 8 | # ssl_certificate /etc/nginx/ssl/default.crt; 9 | # ssl_certificate_key /etc/nginx/ssl/default.key; 10 | server_name localhost; 11 | root /var/www/public; 12 | index index.php index.html index.htm; 13 | client_max_body_size 500M; 14 | 15 | location / { 16 | try_files $uri $uri/ /index.php$is_args$args; 17 | } 18 | 19 | location ~ \.php$ { 20 | try_files $uri =404; 21 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 22 | fastcgi_pass unix:/run/php/php7.4-fpm.sock; 23 | fastcgi_index index.php; 24 | include fastcgi_params; 25 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 26 | fastcgi_param PATH_INFO $fastcgi_path_info; 27 | add_header Access-Control-Allow-Origin *; 28 | } 29 | 30 | error_log /var/log/nginx/localhost.log; 31 | access_log /var/log/nginx/localhost.log; 32 | } 33 | -------------------------------------------------------------------------------- /conf/redis/redis.conf: -------------------------------------------------------------------------------- 1 | maxmemory 512mb 2 | maxmemory-policy allkeys-lru 3 | -------------------------------------------------------------------------------- /conf/supervisor/conf.d/crontab.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:system-cron] 5 | command=cron -f 6 | autostart=true 7 | autorestart=true 8 | stdout_logfile=/var/log/cron.log 9 | -------------------------------------------------------------------------------- /conf/supervisor/conf.d/laravel.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:defaultQueueLaravel] 5 | process_name=%(process_num)s 6 | command=php /var/www/artisan queue:work --tries=2 --daemon --queue=default 7 | autostart=true 8 | autorestart=true 9 | numprocs=1 10 | redirect_stderr=true 11 | stdout_logfile=/var/www/storage/logs/defaultQueueLaravel.log 12 | -------------------------------------------------------------------------------- /conf/supervisor/conf.d/mysql.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:system-mysql] 5 | command=/usr/bin/pidproxy /var/run/mysqld/mysqld.pid /opt/docker/system/program/start-mysql.sh 6 | stop-command= 7 | autostart=true 8 | autorestart=true 9 | stdout_logfile=/var/log/mysql.log 10 | -------------------------------------------------------------------------------- /conf/supervisor/conf.d/nginx.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:system-nginx] 5 | command=nginx -g 'daemon off;' 6 | autostart=true 7 | autorestart=true 8 | stdout_logfile=/var/log/nginx.log 9 | -------------------------------------------------------------------------------- /conf/supervisor/conf.d/phpfpm.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:system-php7.4-fpm] 5 | command=/usr/sbin/php-fpm7.4 -F 6 | autostart=true 7 | autorestart=true 8 | stdout_logfile=/var/log/php-fpm7.4.log 9 | -------------------------------------------------------------------------------- /conf/supervisor/conf.d/redis.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:system-redis] 5 | command=redis-server /etc/redis/redis.conf 6 | autostart=true 7 | autorestart=true 8 | stdout_logfile=/var/log/redis.log 9 | -------------------------------------------------------------------------------- /conf/supervisor/supervisord.conf: -------------------------------------------------------------------------------- 1 | [unix_http_server] 2 | file=/dev/shm/supervisor.sock ; (the path to the socket file) 3 | chmod=0777 ; socket file mode (default 0700) 4 | 5 | [supervisord] 6 | logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log) 7 | logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) 8 | logfile_backups=10 ; (num of main logfile rotation backups;default 10) 9 | loglevel=info ; (log level;default info; others: debug,warn,trace) 10 | pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid) 11 | nodaemon=true ; (start in foreground if true;default false) 12 | minfds=1024 ; (min. avail startup file descriptors;default 1024) 13 | minprocs=200 ; (min. avail process descriptors;default 200) 14 | user=root ; 15 | 16 | ; the below section must remain in the config file for RPC 17 | ; (supervisorctl/web interface) to work, additional interfaces may be 18 | ; added by defining them in separate rpcinterface: sections 19 | [rpcinterface:supervisor] 20 | supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 21 | 22 | [supervisorctl] 23 | serverurl=unix:///dev/shm/supervisor.sock ; use a unix:// URL for a unix socket 24 | 25 | ; The [include] section can just contain the "files" setting. This 26 | ; setting can list multiple files (separated by whitespace or 27 | ; newlines). It can also contain wildcards. The filenames are 28 | ; interpreted as relative to this file. Included files *cannot* 29 | ; include files themselves. 30 | 31 | [include] 32 | files = /etc/supervisor/conf.d/*.conf 33 | 34 | [inet_http_server] ; inet (TCP) server disabled by default 35 | port=*:9001 ; (ip_address:port specifier, *:port for all iface) 36 | ; username=dummy ; (default is no username (open server)) 37 | ; password=dummy ; (default is no password (open server)) -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | laravel: 4 | build: . 5 | ports: 6 | - '${NGINX_PORT}:80' 7 | - '${MYSQL_PORT}:3306' 8 | - '${SUPERVISOR_PORT}:9001' 9 | - '${REDIS_PORT}:6379' 10 | - '${PHPFPM_PORT}:9000' 11 | volumes: 12 | - '../:/var/www' 13 | - 'laravel_root_volume:/root' 14 | - 'laravel_mysql_volume:/var/lib/mysql' 15 | - 'laravel_varlog_volume:/var/log' 16 | environment: 17 | - 'PHP_IDE_CONFIG=${PHP_IDE_CONFIG}' 18 | volumes: 19 | laravel_mysql_volume: null 20 | laravel_varlog_volume: null 21 | laravel_root_volume: null 22 | -------------------------------------------------------------------------------- /docs/tr_TR/GENERAL.md: -------------------------------------------------------------------------------- 1 | # LARAVEL DOCKERIZED 2 | 3 | Laravel için basit docker ortamı. 4 | 5 | ## DESTEKLEDİKLERİ 6 | * nginx 7 | * php-fpm ( v7.2 ) 8 | * mysql ( v5.7 ) 9 | * redis 10 | * crontab 11 | * supervisor 12 | 13 | ## KURULUM 14 | 15 | Çalıştırmak istediğin laravel projesinin bulunduğu dizinde sırasıyla çalıştırmanız gereklidir. 16 | 17 | 1- `git clone git@github.com:kodhub/laravel-dockerized.git .docker` 18 | 19 | 2- `docker-compose up -d --build` 20 | 21 | 3- `docker exec -it bash` 22 | 23 | 4- Projenize ait kurulum adımları. ( `php artisan migrate --seed` vb.) 24 | 25 | ## Ayarlar 26 | 27 | `.env` dosyasından docker ayağa kalkarken gerekli ayarları düzenleyebilirsiniz. Veritabanı bilgilerinizi vb. projenize göre özelleştirebilirsiniz. 28 | 29 | ## CRONTAB AYARLARI 30 | 31 | `./conf/crontab/crontab.conf` dosyası üzerinde yeni cron ekleyebilirsiniz. 32 | 33 | ## MYSQL AYARLARI 34 | 35 | `./conf/mysql/*` klasörü container içindeki `/etc/mysql` klasörüne eşitlenmektedir gerekli dosyaları bu klasöre ekleyerek containeri tekrar başlatabilirsiniz.. 36 | 37 | ## NGINX AYARLARI 38 | 39 | `./conf/nginx/*` klasörü container içindeki `/etc/nginx` klasörüne eşitlenmektedir gerekli dosyaları bu klasöre ekleyerek containeri tekrar başlatabilirsiniz.. 40 | 41 | ## REDIS AYARLARI 42 | 43 | `./conf/redis/*` klasörü container içindeki `/etc/redis` klasörüne eşitlenmektedir gerekli dosyaları bu klasöre ekleyerek containeri tekrar başlatabilirsiniz.. 44 | 45 | ## SUPERVISOR AYARLARI 46 | 47 | `./conf/supervisor/*` klasörü container içindeki `/etc/supervisor` klasörüne eşitlenmektedir gerekli dosyaları bu klasöre ekleyerek containeri tekrar başlatabilirsiniz.. 48 | 49 | ## LARAVEL QUEUE DİNLEYİCİSİ EKLEME 50 | 51 | `./conf/supervisor/conf.d/laravel.conf` dosyası içerisindeki örnek üzerinden projenize ait ekstra queue kanallarını ekleyebilirsiniz. 52 | -------------------------------------------------------------------------------- /opt/installer/3rd-installer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "3RD installer starting..." 3 | 4 | apt update && apt install -ym \ 5 | curl \ 6 | vim \ 7 | cron \ 8 | git \ 9 | zip \ 10 | unzip \ 11 | supervisor 12 | 13 | echo "3RD installer completed..." 14 | 15 | cat /etc/crontab/crontab.conf > /etc/cron.d/crontab.tpl 16 | 17 | while IFS="" read -r p || [[ -n "$p" ]] 18 | do 19 | printf '%s\n' "$p" 20 | (crontab -l && echo "$p") | crontab - 21 | done < /etc/cron.d/crontab.tpl 22 | 23 | echo "Moved crontab conf..." 24 | 25 | -------------------------------------------------------------------------------- /opt/installer/mysql-installer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "Mysql installer starting..." 3 | 4 | # Install mysql 5 | { 6 | echo debconf debconf/frontend select Noninteractive 7 | echo mysql-community-server mysql-community-server/data-dir \ 8 | select '' 9 | echo mysql-community-server mysql-community-server/root-pass \ 10 | password '' 11 | echo mysql-community-server mysql-community-server/re-root-pass \ 12 | password '' 13 | echo mysql-community-server mysql-community-server/remove-test-db \ 14 | select true 15 | } | debconf-set-selections && 16 | apt-get install -y mysql-server mysql-client && rm -rf /var/lib/apt/lists/* 17 | 18 | usermod -d /var/lib/mysql/ mysql 19 | 20 | sed -i "s/bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/mysql.conf.d/mysqld.cnf 21 | 22 | service mysql start 23 | 24 | mysql -e "CREATE DATABASE laravel /*\!40100 DEFAULT CHARACTER SET utf8 */;" 25 | mysql -e "CREATE USER 'root'@'localhost' IDENTIFIED BY '';" 26 | mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '';" 27 | mysql -e "UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User='root';" 28 | mysql -e "FLUSH PRIVILEGES;" 29 | -------------------------------------------------------------------------------- /opt/installer/nginx-installer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "Nginx installer starting.." 3 | 4 | apt clean 5 | 6 | apt update 7 | 8 | apt install nginx -y 9 | -------------------------------------------------------------------------------- /opt/installer/phpfpm-installer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "PHP-FPM installer starting..." 3 | 4 | export DEBIAN_FRONTEND=noninteractive 5 | 6 | echo "deneme"; 7 | 8 | apt install software-properties-common -y 9 | add-apt-repository ppa:ondrej/php 10 | apt update 11 | 12 | apt install -y \ 13 | libcurl4 \ 14 | php7.4-fpm \ 15 | php7.4-curl \ 16 | php7.4-cli \ 17 | php7.4-mysql \ 18 | php7.4-gd \ 19 | php7.4-xsl \ 20 | php7.4-json \ 21 | php7.4-intl \ 22 | php-pear \ 23 | php7.4-dev \ 24 | php7.4-common \ 25 | php7.4-mbstring \ 26 | php7.4-zip \ 27 | php-soap 28 | 29 | php -v 30 | 31 | echo "PHP-FPM installer completed..." 32 | 33 | echo "Composer installer starting..." 34 | 35 | curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 36 | 37 | composer --version 38 | 39 | mkdir -p /run/php 40 | 41 | echo "Composer installer completed..." 42 | -------------------------------------------------------------------------------- /opt/installer/redis-installer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "Mysql installer starting..." 3 | 4 | apt install redis-server php-redis -y -o Dpkg::Options::="--force-confold" 5 | -------------------------------------------------------------------------------- /opt/program/start-mysql.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | exec mysqld_safe 4 | -------------------------------------------------------------------------------- /opt/start.sh: -------------------------------------------------------------------------------- 1 | # INSTALLER RUN 2 | #/opt/system/installer/laravel-installer.sh 3 | # RUN SUPERVISORD 4 | /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf 5 | -------------------------------------------------------------------------------- /storage/.gitignore: -------------------------------------------------------------------------------- 1 | data/* 2 | log/* 3 | root/* 4 | --------------------------------------------------------------------------------