synchronization
This commit is contained in:
16
Docker/Dockerfile/Nginx/Dockerfile
Normal file
16
Docker/Dockerfile/Nginx/Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
||||
# 推荐使用最新版,漏洞会较少,通过漏洞扫描的几率较大
|
||||
#FROM nginx:latest
|
||||
FROM nginx:alpine
|
||||
|
||||
# 初始化 NGINX 配置文件
|
||||
ENV NGINX_ENVSUBST_TEMPLATE_DIR=/etc/nginx/templates \
|
||||
NGINX_ENVSUBST_TEMPLATE_SUFFIX=.template \
|
||||
NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx/conf.d
|
||||
|
||||
COPY ./templates/*.template /etc/nginx/templates/
|
||||
|
||||
COPY ./nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# 自定义初始化变量
|
||||
ENV NGINX_PORT=80 \
|
||||
NGINX_HOST=localhost
|
16
Docker/Dockerfile/Nginx/Dockerfile-node
Normal file
16
Docker/Dockerfile/Nginx/Dockerfile-node
Normal file
@@ -0,0 +1,16 @@
|
||||
# 多阶段构建
|
||||
FROM node:14 as build
|
||||
|
||||
COPY . /app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm config set registry https://registry.npmmirror.com \
|
||||
&& npm install \
|
||||
&& npm run build:prod
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
COPY --from=build /app/dist /app/www
|
||||
|
||||
COPY ./web.conf /etc/nginx/conf.d/default.conf
|
12
Docker/Dockerfile/Nginx/README.md
Normal file
12
Docker/Dockerfile/Nginx/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
*
|
||||
|
||||
> 本文作者:丁辉
|
||||
|
||||
# Nginx 镜像构建
|
||||
|
||||
> Dockerfile示例
|
||||
|
||||
| 文件名 | 示例作用 | 构建示例 |
|
||||
| :-------------: | :-------------------------------------: | :----------------------------------------------: |
|
||||
| Dockerfile | 示例如何通过环境变量更改Nginx配置文件 | docker build -t 镜像名:标签 . |
|
||||
| Dockerfile-ndoe | 示例如何通过过阶段构建,构建Npm前端代码 | docker build -t 镜像名:标签 -f Dockerfile-node . |
|
31
Docker/Dockerfile/Nginx/nginx.conf
Normal file
31
Docker/Dockerfile/Nginx/nginx.conf
Normal file
@@ -0,0 +1,31 @@
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
error_log /var/log/nginx/error.log notice;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
17
Docker/Dockerfile/Nginx/templates/default.conf.template
Normal file
17
Docker/Dockerfile/Nginx/templates/default.conf.template
Normal file
@@ -0,0 +1,17 @@
|
||||
server {
|
||||
listen ${NGINX_PORT};
|
||||
listen [::]:${NGINX_PORT};
|
||||
server_name ${NGINX_HOST};
|
||||
|
||||
#access_log /var/log/nginx/host.access.log main;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
8
Docker/Dockerfile/Nginx/web.conf
Normal file
8
Docker/Dockerfile/Nginx/web.conf
Normal file
@@ -0,0 +1,8 @@
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
location / {
|
||||
root /app/www;
|
||||
index index.html index.htm;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user