Create Dockerfile
Browse files- Dockerfile +28 -0
Dockerfile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM nginx:latest
|
| 2 |
+
|
| 3 |
+
# 安装工具
|
| 4 |
+
RUN apt-get update && apt-get install -y \
|
| 5 |
+
openssl \
|
| 6 |
+
certbot \
|
| 7 |
+
python3-certbot-nginx \
|
| 8 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
# 创建 SSL 证书目录
|
| 11 |
+
RUN mkdir -p /etc/nginx/ssl
|
| 12 |
+
|
| 13 |
+
# 生成自签名证书(生产环境应从外部挂载)
|
| 14 |
+
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
|
| 15 |
+
-keyout /etc/nginx/ssl/nginx.key \
|
| 16 |
+
-out /etc/nginx/ssl/nginx.crt \
|
| 17 |
+
-subj "/C=US/ST=State/L=City/O=Organization/CN=localhost"
|
| 18 |
+
|
| 19 |
+
# 复制配置文件
|
| 20 |
+
COPY nginx-ssl.conf /etc/nginx/nginx.conf
|
| 21 |
+
COPY ssl.conf /etc/nginx/ssl.conf
|
| 22 |
+
|
| 23 |
+
# 复制网站文件
|
| 24 |
+
COPY ./public /usr/share/nginx/html
|
| 25 |
+
|
| 26 |
+
EXPOSE 80 443
|
| 27 |
+
|
| 28 |
+
CMD ["nginx", "-g", "daemon off;"]
|