From 2384171079d8340240327c8074534924067f19ca Mon Sep 17 00:00:00 2001 From: jmal Date: Wed, 28 Jun 2023 15:05:47 +0800 Subject: [PATCH] Update nginx.conf --- Dockerfile | 7 +++++-- docker-entrypoint.sh | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 7a6fe59a..1903977e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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;"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 00000000..0b2f53c0 --- /dev/null +++ b/docker-entrypoint.sh @@ -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 "$@"