Update nginx.conf

This commit is contained in:
jmal 2023-06-28 15:05:47 +08:00
parent 1af86aff2a
commit 2384171079
2 changed files with 13 additions and 2 deletions

View File

@ -14,9 +14,12 @@ FROM nginx:latest
COPY nginx.conf /etc/nginx/nginx.conf
COPY nginx.conf /etc/nginx/nginx.conf.template
COPY --from=builder /app/dist /usr/share/nginx/html
RUN apt-get update && apt-get install -y gettext-base
RUN envsubst '$API_BASE_URL' < /etc/nginx/nginx.conf > /etc/nginx/nginx.conf
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

8
docker-entrypoint.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
set -e
# 使用envsubst命令替换nginx.conf.template文件中的环境变量
envsubst '$API_BASE_URL' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
# 启动Nginx
exec "$@"