@@ -24,8 +24,10 @@ RUN apt-get update && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV FRONTEND_BASE_PATH=/private/argus/web/frontend
|
||||
ENV ARGUS_UID=2133
|
||||
ENV ARGUS_GID=2015
|
||||
ARG ARGUS_UID=2133
|
||||
ARG ARGUS_GID=2015
|
||||
ENV ARGUS_UID=${ARGUS_UID}
|
||||
ENV ARGUS_GID=${ARGUS_GID}
|
||||
|
||||
RUN mkdir -p ${FRONTEND_BASE_PATH} && \
|
||||
mkdir -p /private/argus/etc
|
||||
@@ -82,7 +84,7 @@ COPY src/web/build_tools/frontend/health-check.sh /usr/local/bin/health-check.sh
|
||||
RUN chmod +x /usr/local/bin/health-check.sh
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 80
|
||||
EXPOSE 8080
|
||||
|
||||
# 保持 root 用户,由 supervisor 控制 user 切换
|
||||
USER root
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
docker pull node:20
|
||||
docker pull ubuntu:24.04
|
||||
docker build -f src/web/build_tools/frontend/Dockerfile -t argus-web:0.1.1 .
|
||||
rm -f argus-web-0.1.1.tar && sudo docker image save argus-web:0.1.1 > argus-web-0.1.1.tar
|
||||
export ARGUS_UID=1048
|
||||
export ARGUS_GID=1048
|
||||
|
||||
docker build -f src/web/build_tools/frontend/Dockerfile -t argus-web-frontend:latest .
|
||||
docker save -o argus-web-frontend-latest.tar argus-web-frontend:latest
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
URL="http://127.0.0.1:80"
|
||||
URL="http://127.0.0.1:8080"
|
||||
|
||||
echo "[INFO] Starting Argus web health check loop for $URL..."
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ http {
|
||||
|
||||
# React 前端服务
|
||||
server {
|
||||
listen 80;
|
||||
listen 8080;
|
||||
server_name web.argus.com;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
@@ -24,33 +24,4 @@ http {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Master 服务,需要增加 CORS 支持
|
||||
server {
|
||||
listen 80;
|
||||
server_name master.argus.com;
|
||||
|
||||
location / {
|
||||
proxy_pass http://master.argus.com;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# CORS 支持
|
||||
add_header 'Access-Control-Allow-Origin' 'http://web.argus.com' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization' always;
|
||||
|
||||
if ($request_method = OPTIONS) {
|
||||
add_header 'Access-Control-Allow-Origin' 'http://web.argus.com' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization' always;
|
||||
add_header 'Content-Length' 0;
|
||||
add_header 'Content-Type' 'text/plain';
|
||||
return 204;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,21 +8,12 @@ DNS_SCRIPT="${DNS_DIR}/update-dns.sh"
|
||||
DOMAIN=web.argus.com
|
||||
WEB_DOMAIN_FILE="${DNS_DIR}/${DOMAIN}"
|
||||
RUNTIME_USER="${ARGUS_RUNTIME_USER:-argus}"
|
||||
RUNTIME_UID="${ARGUS_BUILD_UID:-2133}"
|
||||
RUNTIME_GID="${ARGUS_BUILD_GID:-2015}"
|
||||
RUNTIME_UID="${ARGUS_UID:-2133}"
|
||||
RUNTIME_GID="${ARGUS_GID:-2015}"
|
||||
|
||||
mkdir -p "$DNS_DIR"
|
||||
chown -R "$RUNTIME_UID:$RUNTIME_GID" "$DNS_DIR" 2>/dev/null || true
|
||||
|
||||
if [[ -x "$DNS_SCRIPT" ]]; then
|
||||
echo "[INFO] Running update-dns.sh before master starts"
|
||||
# 若脚本存在则执行,保证容器使用 bind 作为 DNS
|
||||
"$DNS_SCRIPT" || echo "[WARN] update-dns.sh execution failed"
|
||||
else
|
||||
echo "[WARN] DNS update script not found or not executable: $DNS_SCRIPT"
|
||||
fi
|
||||
|
||||
|
||||
# 记录容器 IP
|
||||
IP=$(ifconfig | grep -A 1 eth0 | grep inet | awk '{print $2}' || true)
|
||||
if [[ -n "${IP}" ]]; then
|
||||
@@ -32,6 +23,7 @@ if [[ -n "${IP}" ]]; then
|
||||
else
|
||||
echo "[WARN] Failed to detect web IP via ifconfig"
|
||||
fi
|
||||
chmod 755 "$WEB_DOMAIN_FILE"
|
||||
|
||||
echo "[INFO] Launching nginx..."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user