diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3d66038 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Dante Lopez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1272fe0 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# dockdock +Your so-so dockerized local playground. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fb4b981 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: "3" + +networks: + backend: + ipam: + driver: ${NETWORKS_DRIVER} + config: + - subnet: ${IPV4_SUBNET_MASK} + - subnet: ${IPV6_SUBNET_MASK} + +services: + nginx: + build: + context: ./services/nginx + ports: + - "${HOST_NGINX_HTTP_PORT}:${NGINX_EXPOSE_HTTP_PORT}" + volumes: + - ${HOST_APP_DIR}:${NGINX_WEB_ROOT} + - ${NGINX_SITES_PATH}:${NGINX_SITES_AVAILABLE_PATH} + networks: + backend: + ipv4_address: ${IPV4_STATIC_IP} + ipv6_address: ${IPV6_STATIC_IP} \ No newline at end of file diff --git a/env-template b/env-template new file mode 100644 index 0000000..7fdfb05 --- /dev/null +++ b/env-template @@ -0,0 +1,19 @@ +# Host +HOST_APP_DIR=/home/dqlopez/Dev +HOST_NGINX_HTTP_PORT=80 + +# Nginx +NGINX_WEB_ROOT=/var/www/html +NGINX_EXPOSE_HTTP_PORT=80 +NGINX_SITES_PATH=./services/nginx/sites/ +NGINX_SITES_AVAILABLE_PATH=/etc/nginx/sites-available + +# Drivers +VOLUMES_DRIVER=local +NETWORKS_DRIVER=default + +# Networks +IPV4_STATIC_IP=172.16.238.10 +IPV6_STATIC_IP=2001:3984:3989::10 +IPV4_SUBNET_MASK=172.16.238.0/24 +IPV6_SUBNET_MASK=2001:3984:3989::/64 \ No newline at end of file diff --git a/services/nginx/Dockerfile b/services/nginx/Dockerfile new file mode 100644 index 0000000..f05353a --- /dev/null +++ b/services/nginx/Dockerfile @@ -0,0 +1,13 @@ +FROM nginx:stable-alpine + +LABEL maintainer="Dante Lopez " + +WORKDIR /var/www/html + +RUN rm /etc/nginx/conf.d/default.conf + +COPY nginx.conf /etc/nginx/ + +COPY default.conf /etc/nginx/conf.d/ + +EXPOSE 80 \ No newline at end of file diff --git a/services/nginx/default.conf b/services/nginx/default.conf new file mode 100644 index 0000000..c90516a --- /dev/null +++ b/services/nginx/default.conf @@ -0,0 +1,24 @@ +server { + + listen 80 default_server; + listen [::]:80 default_server ipv6only=on; + + # For https + # listen 443 ssl default_server; + # listen [::]:443 ssl default_server ipv6only=on; + # ssl_certificate /etc/nginx/ssl/default.crt; + # ssl_certificate_key /etc/nginx/ssl/default.key; + + server_name localhost; + root /usr/share/nginx/html; + index index.php index.html index.htm; + + location ~ /\.ht { + deny all; + } + + location /.well-known/acme-challenge/ { + root /var/www/letsencrypt/; + log_not_found off; + } +} diff --git a/services/nginx/nginx.conf b/services/nginx/nginx.conf new file mode 100644 index 0000000..de655c4 --- /dev/null +++ b/services/nginx/nginx.conf @@ -0,0 +1,27 @@ +worker_processes 4; +pid /run/nginx.pid; + +events { + worker_connections 2048; +} + +http { + server_tokens off; + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 15; + types_hash_max_size 2048; + client_max_body_size 20M; + include /etc/nginx/mime.types; + default_type application/octet-stream; + access_log /dev/stdout; + error_log /dev/stderr; + gzip on; + gzip_disable "msie6"; + + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-available/*.conf; + open_file_cache off; + charset UTF-8; +} \ No newline at end of file diff --git a/services/nginx/sites/app.conf.template b/services/nginx/sites/app.conf.template new file mode 100644 index 0000000..dca7504 --- /dev/null +++ b/services/nginx/sites/app.conf.template @@ -0,0 +1,43 @@ +server { + + listen 80; + listen [::]:80; + + # For https + # listen 443 ssl; + # listen [::]:443 ssl ipv6only=on; + # ssl_certificate /etc/nginx/ssl/default.crt; + # ssl_certificate_key /etc/nginx/ssl/default.key; + + server_name app.local; + root /var/www/html; + index index.php index.html index.htm; + + location / { + try_files $uri $uri/ /index.php$is_args$args; + } + + location ~ \.php$ { + try_files $uri /index.php =404; + fastcgi_pass php-upstream; + fastcgi_index index.php; + fastcgi_buffers 16 16k; + fastcgi_buffer_size 32k; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + #fixes timeouts + fastcgi_read_timeout 600; + include fastcgi_params; + } + + location ~ /\.ht { + deny all; + } + + location /.well-known/acme-challenge/ { + root /var/www/letsencrypt/; + log_not_found off; + } + + error_log /var/log/nginx/app_error.log; + access_log /var/log/nginx/app_access.log; +} \ No newline at end of file diff --git a/services/nginx/sites/test.conf b/services/nginx/sites/test.conf new file mode 100644 index 0000000..2ee1d5c --- /dev/null +++ b/services/nginx/sites/test.conf @@ -0,0 +1,27 @@ +server { + + listen 80; + listen [::]:80; + + # For https + # listen 443 ssl; + # listen [::]:443 ssl ipv6only=on; + # ssl_certificate /etc/nginx/ssl/default.crt; + # ssl_certificate_key /etc/nginx/ssl/default.key; + + server_name test.local; + root /var/www/html/personal/test; + index index.php index.html index.htm; + + location ~ /\.ht { + deny all; + } + + location /.well-known/acme-challenge/ { + root /var/www/letsencrypt/; + log_not_found off; + } + + error_log /var/log/nginx/app_error.log; + access_log /var/log/nginx/app_access.log; +} \ No newline at end of file