From 428e2e4e38fcdfed6442de4237c2d5eefb65b3ca Mon Sep 17 00:00:00 2001 From: wandoubaba Date: Thu, 25 Apr 2024 18:18:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=86=E5=A4=87=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++ dist/index.html | 18 +++++++ docker-compose.yml | 17 +++++++ docker-entrypoint.sh | 13 +++++ nginx.conf | 118 +++++++++++++++++++++++++++++++++++++++++++ npm | 4 ++ 6 files changed, 174 insertions(+) create mode 100644 .gitignore create mode 100755 dist/index.html create mode 100644 docker-compose.yml create mode 100755 docker-entrypoint.sh create mode 100644 nginx.conf create mode 100755 npm diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ca79c6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/dist/* +!/dist/index.html +node_modules +!.gitignore \ No newline at end of file diff --git a/dist/index.html b/dist/index.html new file mode 100755 index 0000000..b43e527 --- /dev/null +++ b/dist/index.html @@ -0,0 +1,18 @@ + + + + + + node & nginx + + +
+

欢迎

+

node & nginx

+
+
+ https://git.wandoubaba.com/wandoubaba/docker-node +
+
+ + \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c7ec0d0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: "3.1" + +services: + node-nginx: + image: wandoubaba517/node-nginx:20 + container_name: node-nginx + ports: + - 60000:80 + environment: + - NODE_OPTIONS=--max-old-space-size=4096 + volumes: + - ./docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh + - ./:/app/web + - ./nginx.conf:/usr/local/nginx/conf/nginx.conf + - ./dist:/usr/local/nginx/html + working_dir: /app/web + stdin_open: true diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..5d61b89 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + set -- node "$@" +fi + +nginx + +exec "$@" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..b381022 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,118 @@ + +#user nobody; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +#error_log logs/error.log info; + +#pid logs/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include 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 logs/access.log main; + + sendfile on; + #tcp_nopush on; + + #keepalive_timeout 0; + keepalive_timeout 65; + + #gzip on; + + server { + listen 80; + server_name localhost; + + #charset koi8-r; + + #access_log logs/host.access.log main; + + location / { + root html; + index index.html index.htm; + try_files $uri $uri/ /index.html last; + } + + #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 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; + #} + } + + + # another virtual host using mix of IP-, name-, and port-based configuration + # + #server { + # listen 8000; + # listen somename:8080; + # server_name somename alias another.alias; + + # location / { + # root html; + # index index.html index.htm; + # } + #} + + + # HTTPS server + # + #server { + # listen 443 ssl; + # server_name localhost; + + # ssl_certificate cert.pem; + # ssl_certificate_key cert.key; + + # ssl_session_cache shared:SSL:1m; + # ssl_session_timeout 5m; + + # ssl_ciphers HIGH:!aNULL:!MD5; + # ssl_prefer_server_ciphers on; + + # location / { + # root html; + # index index.html index.htm; + # } + #} + +} diff --git a/npm b/npm new file mode 100755 index 0000000..42a2020 --- /dev/null +++ b/npm @@ -0,0 +1,4 @@ +#!/bin/bash + +# docker compose run --rm node-nginx npm --registry https://registry.npm.taobao.org "$@" +docker compose run --rm node-nginx npm "$@"