From ea6d0eea7c0c77df081333bc51f7eb5d393c07b8 Mon Sep 17 00:00:00 2001 From: Kekskurse Date: Thu, 26 Sep 2019 14:00:05 +0200 Subject: [PATCH] Stuff --- .env.example | 8 ++++---- docker-compose.yml | 30 ++++++++++++++++++++++++++++++ docker/Dockerfile-fpm | 8 ++++++++ docker/Dockerfile-nginx | 4 ++++ docker/nginx.conf | 21 +++++++++++++++++++++ docker/start-fpm.sh | 10 ++++++++++ resources/views/index.php | 33 +++++++++++++++++++++++++++++++++ routes/web.php | 3 ++- 8 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 docker-compose.yml create mode 100644 docker/Dockerfile-fpm create mode 100644 docker/Dockerfile-nginx create mode 100644 docker/nginx.conf create mode 100644 docker/start-fpm.sh create mode 100644 resources/views/index.php diff --git a/.env.example b/.env.example index 7719445..ccac5db 100644 --- a/.env.example +++ b/.env.example @@ -9,11 +9,11 @@ LOG_CHANNEL=stack LOG_SLACK_WEBHOOK_URL= DB_CONNECTION=mysql -DB_HOST=127.0.0.1 +DB_HOST=mariadb DB_PORT=3306 -DB_DATABASE=homestead -DB_USERNAME=homestead -DB_PASSWORD=secret +DB_DATABASE=dev +DB_USERNAME=dev +DB_PASSWORD=dev CACHE_DRIVER=file QUEUE_CONNECTION=sync diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..eb6eb6f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +version: '3.2' +services: + php: + build: + context: ./ + dockerfile: docker/Dockerfile-fpm + volumes: + - ./:/app + links: + - mariadb + nginx: + build: + context: ./ + dockerfile: docker/Dockerfile-nginx + volumes: + - ./:/app + - ./docker/nginx.conf:/etc/nginx/conf.d/default.conf + ports: + - 8083:80 + links: + - php + mariadb: + image: mariadb:10.4.4 + ports: + - 3306:3306 + environment: + MYSQL_ROOT_PASSWORD: example + MYSQL_DATABASE: dev + MYSQL_USER: dev + MYSQL_PASSWORD: dev diff --git a/docker/Dockerfile-fpm b/docker/Dockerfile-fpm new file mode 100644 index 0000000..e5aff4f --- /dev/null +++ b/docker/Dockerfile-fpm @@ -0,0 +1,8 @@ +FROM php:7.3.5-fpm-alpine3.9 + +RUN docker-php-ext-install pdo pdo_mysql +WORKDIR /app + +COPY ./ /app + +CMD ["sh", "/app/docker/start-fpm.sh"] diff --git a/docker/Dockerfile-nginx b/docker/Dockerfile-nginx new file mode 100644 index 0000000..6853f8a --- /dev/null +++ b/docker/Dockerfile-nginx @@ -0,0 +1,4 @@ +FROM nginx:1.15.12-alpine + +COPY ./ /app +COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..d1cde6c --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,21 @@ + server { + index index.php index.html; + server_name php-docker.local; + error_log /var/log/nginx/error.log; + access_log /var/log/nginx/access.log; + root /app/public; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + try_files $uri /index.php =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + } + } diff --git a/docker/start-fpm.sh b/docker/start-fpm.sh new file mode 100644 index 0000000..e6d88fd --- /dev/null +++ b/docker/start-fpm.sh @@ -0,0 +1,10 @@ +cd /app +until nc -z -v -w30 mariadb 3306 +do + echo "Waiting for database connection..." + # wait for 5 seconds before check again + sleep 5 +done +sleep 5 +php artisan migrate --force +php-fpm diff --git a/resources/views/index.php b/resources/views/index.php new file mode 100644 index 0000000..c473b68 --- /dev/null +++ b/resources/views/index.php @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/routes/web.php b/routes/web.php index 0f73f16..111d7f7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -12,5 +12,6 @@ */ $router->get('/', function () use ($router) { - return $router->app->version(); + return view('index', ['name' => 'James']); + #return $router->app->version(); });