浏览代码

New nginx 1.18 image, updated readme for with-samples install #257

Mark Shust 5 年之前
父节点
当前提交
706fd36a72

+ 10 - 2
README.md

@@ -137,13 +137,21 @@ This configuration has been tested on Mac & Linux. Windows is supported through
 
 ### Automated Setup (New Project)
 
-Run this automated one-liner from the directory you want to install your project to:
+Run this automated one-liner from the directory you want to install your project.
+
+#### No sample data
 
 ```bash
 curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/onelinesetup | bash -s -- magento2.test 2.3.5-p1
 ```
 
-The `magento2.test` above defines the hostname to use, and the `2.3.4` defines the Magento version to install. Note that since we need a write to `/etc/hosts` for DNS resolution, you will be prompted for your system password during setup.
+#### With sample data
+
+```bash
+curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/onelinesetup | bash -s -- magento2.test with-samples-2.3.5-p1
+```
+
+The `magento2.test` above defines the hostname to use, and the `2.3.5-p1` defines the Magento version to install. Note that since we need a write to `/etc/hosts` for DNS resolution, you will be prompted for your system password during setup.
 
 After the one-liner above completes running, you should be able to access your site at `https://magento2.test`.
 

+ 32 - 0
images/nginx/1.18/Dockerfile

@@ -0,0 +1,32 @@
+FROM nginx:1.18
+MAINTAINER Mark Shust <mark@shust.com>
+
+RUN groupadd -g 1000 app \
+ && useradd -g 1000 -u 1000 -d /var/www -s /bin/bash app
+RUN touch /var/run/nginx.pid
+RUN mkdir /sock
+
+RUN apt-get update && apt-get install -y \
+  curl \
+  libnss3-tools \
+  openssl
+
+RUN ( \
+  cd /usr/local/bin/ \
+  && curl -L https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-linux-amd64 -o mkcert \
+  && chmod +x mkcert \
+  )
+
+COPY ./conf/nginx.conf /etc/nginx/
+COPY ./conf/default.conf /etc/nginx/conf.d/
+
+RUN mkdir -p /etc/nginx/html /var/www/html \
+  && chown -R app:app /etc/nginx /var/www /var/cache/nginx /var/run/nginx.pid /sock
+
+EXPOSE 8443
+
+USER app:app
+
+VOLUME /var/www
+
+WORKDIR /var/www/html

+ 22 - 0
images/nginx/1.18/conf/default.conf

@@ -0,0 +1,22 @@
+upstream fastcgi_backend {
+  server unix:/sock/docker.sock;
+}
+
+server {
+  listen 8000;
+  return 301 https://$host$request_uri;
+}
+
+server {
+  listen 8443 ssl;
+
+  ssl_certificate /etc/nginx/certs/nginx.crt;
+  ssl_certificate_key /etc/nginx/certs/nginx.key;
+
+  set $MAGE_ROOT /var/www/html;
+
+  fastcgi_buffer_size 64k;
+  fastcgi_buffers 8 128k;
+
+  include /var/www/html/nginx[.]conf;
+}

+ 35 - 0
images/nginx/1.18/conf/default.magento1.conf

@@ -0,0 +1,35 @@
+upstream fastcgi_backend {
+  server unix:/sock/docker.sock;
+}
+
+server {
+  listen 8000;
+  server_name localhost;
+
+  set $MAGE_ROOT /var/www/html;
+  set $MAGE_IS_DEVELOPER_MODE true;
+
+  root $MAGE_ROOT;
+
+  index index.php;
+  autoindex off;
+  charset off;
+
+  add_header 'X-Content-Type-Options' 'nosniff';
+
+  location / {
+    try_files $uri $uri/ /index.php?$args;
+  }
+  
+  location ~ cron\.php {
+    deny all;
+  }
+
+  location ~* \.php$ {
+    try_files $uri =404;
+    fastcgi_pass fastcgi_backend;
+    fastcgi_index index.php;
+    fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
+    include fastcgi_params;
+  }
+}

+ 34 - 0
images/nginx/1.18/conf/nginx.conf

@@ -0,0 +1,34 @@
+# let's assume dual-core machine
+worker_processes 2;
+
+error_log /var/log/nginx/error.log debug;
+pid /var/run/nginx.pid;
+
+events {
+  # this should be equal to value of "ulimit -n"
+  # reference: https://www.digitalocean.com/community/tutorials/how-to-optimize-nginx-configuration
+  worker_connections 1048576;
+}
+
+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;
+
+  client_max_body_size 20M;
+
+  include /etc/nginx/conf.d/*.conf;
+}