33 lines
993 B
Docker
33 lines
993 B
Docker
FROM python:3.11-alpine
|
|
|
|
# 安装 nginx
|
|
RUN apk add --no-cache nginx
|
|
|
|
# 创建工作目录
|
|
WORKDIR /app
|
|
|
|
# 复制生成器脚本
|
|
COPY generator.py /app/
|
|
COPY index.html /usr/share/nginx/html/
|
|
|
|
# 创建 nginx 配置
|
|
RUN mkdir -p /run/nginx && \
|
|
echo 'server {' > /etc/nginx/http.d/default.conf && \
|
|
echo ' listen 80;' >> /etc/nginx/http.d/default.conf && \
|
|
echo ' root /usr/share/nginx/html;' >> /etc/nginx/http.d/default.conf && \
|
|
echo ' index index.html;' >> /etc/nginx/http.d/default.conf && \
|
|
echo ' location / {' >> /etc/nginx/http.d/default.conf && \
|
|
echo ' try_files $uri $uri/ =404;' >> /etc/nginx/http.d/default.conf && \
|
|
echo ' }' >> /etc/nginx/http.d/default.conf && \
|
|
echo '}' >> /etc/nginx/http.d/default.conf
|
|
|
|
# 启动脚本
|
|
RUN echo '#!/bin/sh' > /app/start.sh && \
|
|
echo 'nginx' >> /app/start.sh && \
|
|
echo 'python3 /app/generator.py' >> /app/start.sh && \
|
|
chmod +x /app/start.sh
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["/app/start.sh"]
|