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 "$@"