diff --git a/.gitignore b/.gitignore index 43e1fd9bfbd2595c6d36b4e2b8d463766bf7ec62..26a203d6571c7e3e2250f32c2424341d76be4096 100644 --- a/.gitignore +++ b/.gitignore @@ -12,5 +12,7 @@ Homestead.yaml /public/css/*.css /public/js/*.js !/public/js/turf.min.js +.composer public/mix-manifest.json package-lock.json +composer.lock diff --git a/DockerfileDev b/DockerfileDev new file mode 100644 index 0000000000000000000000000000000000000000..d73642d36f40ee13501694a24974fb6cbdc8f41d --- /dev/null +++ b/DockerfileDev @@ -0,0 +1,67 @@ +FROM alpine:3.11.3 + +RUN apk add --update \ + nginx \ + tzdata \ + ca-certificates \ + dcron \ + zip \ + redis \ + php7 \ + php7-fpm \ + php7-common \ + php7-curl \ + php7-mbstring \ + php7-sqlite3 \ + php7-pdo_mysql \ + php7-pdo_sqlite \ + php7-dom \ + php7-simplexml \ + php7-tokenizer \ + php7-zip \ + php7-redis \ + php7-gd \ + php7-json \ + php7-pcntl \ + php7-fileinfo \ + php7-xdebug \ + && rm -rf /var/cache/apk/* + +WORKDIR /html + +RUN sed -i 's/;error_log = log\/php7\/error.log/error_log = \/dev\/stderr/g' /etc/php7/php-fpm.conf && \ + sed -i 's/;daemonize = yes/daemonize = no/g' /etc/php7/php-fpm.conf && \ + sed -i 's/listen = 127.0.0.1:9000/listen = 9000/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/;request_terminate_timeout = 0/request_terminate_timeout = 900/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/;request_terminate_timeout_track_finished = no/request_terminate_timeout_track_finished = yes/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/;decorate_workers_output = no/decorate_workers_output = no/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/;catch_workers_output = yes/catch_workers_output = yes/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/user = nobody/user = nginx/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/group = nobody/group = nginx/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/pm.max_children = 5/pm.max_children = 100/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/pm.start_servers = 2/pm.start_servers = 5/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/pm.min_spare_servers = 1/pm.min_spare_servers = 5/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/pm.max_spare_servers = 3/pm.max_spare_servers = 25/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/user = www-data/user = nginx/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/group = www-data/group = nginx/g' /etc/php7/php-fpm.d/www.conf && \ + sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php7/php.ini && \ + sed -i 's/expose_php = On/expose_php = Off/g' /etc/php7/php.ini && \ + sed -i 's/;zend_extension=xdebug.so/zend_extension=xdebug.so/g' /etc/php7/conf.d/xdebug.ini && \ + echo "xdebug.remote_enable = 1" >> /etc/php7/conf.d/xdebug.ini && \ + echo "xdebug.remote_autostart = 1" >> /etc/php7/conf.d/xdebug.ini && \ + echo "xdebug.remote_connect_back = 1" >> /etc/php7/conf.d/xdebug.ini && \ + echo "xdebug.idekey=VSCODE" >> /etc/php7/conf.d/xdebug.ini && \ + echo "daemonize yes" >> /etc/redis.conf && \ + ln -s /dev/null /var/log/nginx/access.log && \ + ln -s /dev/stdout /var/log/nginx/error.log && \ + cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime && \ + echo "Europe/Berlin" > /etc/timezone && \ + (crontab -l ; echo "* * * * * php /html/artisan schedule:run >> /dev/null 2>&1") | crontab - + +WORKDIR /html +EXPOSE 80 + +CMD chown -R root:nginx storage/ bootstrap/cache && \ + chmod -R g+w storage/ bootstrap/cache && \ + crond -L /dev/stdout && \ + php-fpm7 diff --git a/config/nginx-default-dev.conf b/config/nginx-default-dev.conf new file mode 100644 index 0000000000000000000000000000000000000000..0424e725ec0a6ef5844cad5dd64bd58e149d3bee --- /dev/null +++ b/config/nginx-default-dev.conf @@ -0,0 +1,55 @@ +server { + listen 80; + server_name localhost; + root /html/public; + index index.php index.html index.htm; + + #charset koi8-r; + #access_log /var/log/nginx/host.access.log main; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + try_files $uri /index.php =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass phpfpm:9000; + fastcgi_index index.php; + fastcgi_read_timeout 900; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} +} \ No newline at end of file diff --git a/config/nginx.conf b/config/nginx.conf new file mode 100644 index 0000000000000000000000000000000000000000..96b512b5d167229b8eeb3fd3fc35865e455ef503 --- /dev/null +++ b/config/nginx.conf @@ -0,0 +1,33 @@ + +user nginx; +worker_processes 100; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +daemon off; + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + gzip on; + + include /etc/nginx/conf.d/*.conf; +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..d153ec29f2bcd3f88b8df94a6c36e8b788506893 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,49 @@ +version: '3.7' +services: + phpdeps: + image: registry.metager.de/open-source/composer/master + working_dir: /app + volumes: + - .:/app + - .composer:/root/.composer + command: composer install + assets: + image: node:10 + volumes: + - .:/usr/src/app + working_dir: /usr/src/app + command: bash -c "npm install && npm run watch" + phpfpm: + depends_on: + - "phpdeps" + - "assets" + restart: on-failure + build: + context: . + dockerfile: DockerfileDev + image: metagermaps:latest + working_dir: /html + volumes: + - .:/html + nginx: + depends_on: + - "phpfpm" + restart: on-failure + image: metagermaps:latest + working_dir: /html + command: nginx + volumes: + - .:/html + - ./config/nginx.conf:/etc/nginx/nginx.conf + - ./config/nginx-default-dev.conf:/etc/nginx/conf.d/default.conf + ports: + - "8080:80" + init: + depends_on: + - "phpfpm" + restart: on-failure + image: metagermaps:latest + working_dir: /html + command: /bin/sh init.sh + volumes: + - .:/html \ No newline at end of file diff --git a/init.sh b/init.sh new file mode 100644 index 0000000000000000000000000000000000000000..84219da825e81f79deac53327aa335836bc37fd1 --- /dev/null +++ b/init.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ ! -f .env ] +then + cp .env.example .env + php artisan key:generate +fi \ No newline at end of file