re_create_config.sh 1.44 KB
# 删除现有的 ConfigMap
kubectl delete configmap -n ecommerce frontend-config

# 重新创建包含所有必要键的 ConfigMap
kubectl create configmap -n ecommerce frontend-config \
  --from-literal=nginx.conf="
events {
    worker_connections 1024;
}

http {
    client_body_temp_path /tmp/nginx-client-body;
    proxy_temp_path /tmp/nginx-proxy;
    fastcgi_temp_path /tmp/nginx-fastcgi;
    uwsgi_temp_path /tmp/nginx-uwsgi;
    scgi_temp_path /tmp/nginx-scgi;
    
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    
    server {
        listen 80;
        server_name localhost;
        root /usr/share/nginx/html;
        index index.html;

        location / {
            try_files \$uri \$uri/ /index.html;
        }

        location /api/ {
            proxy_pass https://api.awsmpc.asia/;
            proxy_set_header Host api.awsmpc.asia;
        }

        location /health {
            return 200 'healthy\n';
        }
    }
}" \
  --from-literal=API_URL="https://api.awsmpc.asia" \
  --from-literal=APP_NAME="Ecommerce Platform" \
  --from-literal=environment.js="
window.env = {
  API_URL: 'https://api.awsmpc.asia',
  APP_NAME: 'Ecommerce Platform',
  NODE_ENV: 'production',
  REACT_APP_VERSION: '1.1.2',
  REACT_APP_BUILD_VERSION: '83',
  REACT_APP_GIT_COMMIT: 'ce645477c7d65f766256b53f4ac098a20c9a3da6',
  REACT_APP_ENABLE_ANALYTICS: 'true',
  REACT_APP_ENABLE_DEBUG: 'false',
  REACT_APP_ENABLE_PWA: 'true'
};"