Skip to content

Commit

Permalink
Update nginx.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
jamebal committed Jun 28, 2023
1 parent 1af86af commit 2384171
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 8 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit 2384171

Please sign in to comment.