test-frontend/deploy/Dockerfile

24 lines
821 B
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ============================================
# 前端镜像 — 宿主机构建 distDocker 打包 Nginx
# 启动时通过 BACKEND_PROXY 环境变量指定后端地址
# ============================================
FROM nginx:alpine
LABEL maintainer="ghb-base deploy"
# 安装 envsubstgettext 包提供)
RUN apk add --no-cache gettext
COPY deploy/nginx/default.conf /etc/nginx/templates/default.conf.template
COPY dist /usr/share/nginx/html
EXPOSE 80
# envsubst 会将模板中 ${BACKEND_PROXY} 替换为实际值
# 单体模式: http://ghb-backend:8081/ghb
# Cloud 模式: http://ghb-gateway:9999/ghb
ENV BACKEND_PROXY=http://ghb-backend:8081/ghb
CMD ["/bin/sh", "-c", "envsubst '${BACKEND_PROXY}' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"]