From bf1bc29156b34ea2eca36c148d2d889d2644b36e Mon Sep 17 00:00:00 2001 From: Babibubebon Date: Tue, 1 Sep 2020 03:28:41 +0900 Subject: [PATCH] Add Dockerfiles --- .dockerignore | 8 ++++++++ .editorconfig | 2 +- .env.example | 9 +-------- README.md | 3 ++- docker-compose.dev.yml | 22 ++++++++++++++++++++++ docker-compose.yml | 13 +++++++++++++ docker/nginx/Dockerfile | 4 ++++ docker/nginx/default.conf | 27 +++++++++++++++++++++++++++ docker/php/Dockerfile | 8 ++++++++ 9 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 .dockerignore create mode 100644 docker-compose.dev.yml create mode 100644 docker-compose.yml create mode 100644 docker/nginx/Dockerfile create mode 100644 docker/nginx/default.conf create mode 100644 docker/php/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..76f3959 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.env +.git +.idea +vendor +storage/app/* +storage/framework/cache/* +storage/framework/views/* +storage/logs/* diff --git a/.editorconfig b/.editorconfig index 6537ca4..093a5a6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,5 +11,5 @@ trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false -[*.{yml,yaml}] +[*.{yml,yaml,conf}] indent_size = 2 diff --git a/.env.example b/.env.example index fa0b8bc..2816d90 100644 --- a/.env.example +++ b/.env.example @@ -1,19 +1,12 @@ APP_NAME=lodfe APP_ENV=local APP_KEY= -APP_DEBUG=true +APP_DEBUG=false APP_URL=http://localhost APP_TIMEZONE=UTC LOG_CHANNEL=stack LOG_SLACK_WEBHOOK_URL= -DB_CONNECTION=mysql -DB_HOST=127.0.0.1 -DB_PORT=3306 -DB_DATABASE=homestead -DB_USERNAME=homestead -DB_PASSWORD=secret - CACHE_DRIVER=file QUEUE_CONNECTION=sync diff --git a/README.md b/README.md index 6c980ff..ceabed0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ SPARQLエンドポイントを用いたLinked Open Dataフロントエンド([Pu ## Installation ``` +$ git clone https://github.com/Babibubebon/lodfe.git +$ cd lodfe $ composer install -$ cp .env{.example,} $ cp config/datasets.php{.example,} ``` diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..f7895bc --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,22 @@ +version: "3" +services: + php: + image: babibubebon/lodfe:latest-php + build: + context: . + dockerfile: ./docker/php/Dockerfile + volumes: + - ./:/var/www/lodfe + + nginx: + image: babibubebon/lodfe:latest-nginx + build: + context: . + dockerfile: ./docker/nginx/Dockerfile + ports: + - 80:80 + depends_on: + - php + volumes: + - ./:/var/www/lodfe + - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..12f589a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: "3" +services: + php: + image: babibubebon/lodfe:latest-php + volumes: + - ./config/datasets.php:/var/www/lodfe/config/datasets.php:ro + + nginx: + image: babibubebon/lodfe:latest-nginx + ports: + - 80:80 + depends_on: + - php diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile new file mode 100644 index 0000000..3cafd03 --- /dev/null +++ b/docker/nginx/Dockerfile @@ -0,0 +1,4 @@ +FROM nginx:1.19-alpine + +ADD ./docker/nginx/default.conf /etc/nginx/conf.d/default.conf +ADD ./public /var/www/lodfe/public diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf new file mode 100644 index 0000000..6e81c50 --- /dev/null +++ b/docker/nginx/default.conf @@ -0,0 +1,27 @@ +server { + listen 80 default_server; + server_name _; + root /var/www/lodfe/public; + + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Content-Type-Options "nosniff"; + + index index.php; + + charset utf-8; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + fastcgi_pass php:9000; + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + include fastcgi_params; + } + + location ~ /\.(?!well-known).* { + deny all; + } +} diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile new file mode 100644 index 0000000..da0bffe --- /dev/null +++ b/docker/php/Dockerfile @@ -0,0 +1,8 @@ +FROM php:7.4-fpm-alpine + +ARG WORKDIR=/var/www/lodfe +WORKDIR ${WORKDIR} + +COPY --from=composer /usr/bin/composer /usr/bin/composer +ADD --chown=www-data:www-data . /var/www/lodfe +RUN composer install