准备提交

This commit is contained in:
wandoubaba 2024-04-25 18:18:55 +08:00
commit 428e2e4e38
6 changed files with 174 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/dist/*
!/dist/index.html
node_modules
!.gitignore

18
dist/index.html vendored Executable file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>node & nginx</title>
</head>
<body>
<div style="margin:0 auto; width:96%">
<h1>欢迎</h1>
<h2>node & nginx</h2>
<hr>
<div>
<a href="https://git.wandoubaba.com/wandoubaba/docker-node">https://git.wandoubaba.com/wandoubaba/docker-node</a>
</div>
</div>
</body>
</html>

17
docker-compose.yml Normal file
View File

@ -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

13
docker-entrypoint.sh Executable file
View File

@ -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 "$@"

118
nginx.conf Normal file
View File

@ -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;
# }
#}
}

4
npm Executable file
View File

@ -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 "$@"