@@ -22,73 +22,65 @@ COPY . .
2222# Build the application
2323RUN pnpm run build
2424
25- # Stage 2: Production server
26- FROM nginx:alpine
27-
28- # Simple nginx config for EasyPanel (no API proxy - EasyPanel handles routing)
29- COPY <<EOF /etc/nginx/conf.d/default.conf
30- server {
31- listen 80;
32- server_name _;
33- root /usr/share/nginx/html;
34- index index.html;
35-
36- # Handle React Router - all routes should serve index.html
37- location / {
38- try_files \$ uri \$ uri/ /index.html;
39- }
40-
41- # Health check for EasyPanel monitoring
42- location /health {
43- access_log off;
44- return 200 "healthy" ;
45- add_header Content-Type text/plain;
46- }
47-
48- # Basic security headers
49- add_header X-Frame-Options "SAMEORIGIN" ;
50- add_header X-Content-Type-Options "nosniff" ;
51-
52- # Enable gzip compression
53- gzip on;
54- gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
55- }
56- EOF
25+ # Stage 2: Production server using Vite preview
26+ FROM node:18-alpine
27+
28+ # Set working directory
29+ WORKDIR /app
5730
58- # Copy built application from build stage
59- COPY --from=build /app/dist /usr/share/nginx/html
31+ # Install pnpm globally
32+ RUN npm install -g pnpm@9.0.0
33+
34+ # Copy built application and necessary files from build stage
35+ COPY --from=build /app/dist ./dist
36+ COPY --from=build /app/package.json ./package.json
37+ COPY --from=build /app/pnpm-lock.yaml ./pnpm-lock.yaml
38+ COPY --from=build /app/vite.config.ts ./vite.config.ts
39+ COPY --from=build /app/tsconfig.json ./tsconfig.json
40+ COPY --from=build /app/tsconfig.node.json ./tsconfig.node.json
41+
42+ # Install all dependencies (needed for Vite preview with config)
43+ RUN pnpm install --frozen-lockfile
6044
6145# Copy docker entrypoint script
6246COPY <<EOF /docker-entrypoint.sh
6347# !/bin/sh
6448
6549# Simple startup logging
66- echo "🚀 Starting Unified Arda Platform"
50+ echo "🚀 Starting Unified Arda Platform with Vite Preview Server "
6751echo "Backend: \$ {VITE_SERVER_URL:-http://localhost:8080}"
52+ echo "Chat Agent: \$ {VITE_CHAT_AGENT_URL:-http://localhost:3002}"
53+ echo "Environment: \$ {VITE_SERVER_ENVIRONMENT:-production}"
6854
6955# Inject environment variables into the built app
70- # This allows runtime configuration changes without rebuilding
71- cat > /usr/share/nginx/html/env-config.js << EOL
56+ cat > /app/dist/env-config.js << EOL
7257window.__ENV__ = {
73- VITE_SERVER_URL: "\$ {VITE_SERVER_URL:-http://backend :8080}" ,
58+ VITE_SERVER_URL: "\$ {VITE_SERVER_URL:-http://arda-credit_server :8080}" ,
7459 VITE_SERVER_ENVIRONMENT: "\$ {VITE_SERVER_ENVIRONMENT:-production}" ,
75- VITE_CHAT_AGENT_URL: "\$ {VITE_CHAT_AGENT_URL:-http://chat -agent:3002}" ,
60+ VITE_CHAT_AGENT_URL: "\$ {VITE_CHAT_AGENT_URL:-http://arda-credit_chat -agent:3002}" ,
7661 VITE_ETHEREUM_RPC_URL: "\$ {VITE_ETHEREUM_RPC_URL:-http://127.0.0.1:8545}"
7762};
7863EOL
7964
80- echo "✅ Environment injected, starting nginx..."
81- exec nginx -g 'daemon off;'
65+ echo "✅ Environment injected, starting Vite preview server..."
66+ echo "Server will be available on http://0.0.0.0:3000"
67+
68+ # Start Vite preview server
69+ echo "🚀 Starting Vite preview server on http://0.0.0.0:3000"
70+ echo "✅ Proxy configuration active for all backend services"
71+
72+ # Run Vite preview server in foreground - Docker health check handles verification
73+ exec pnpm run preview --host 0.0.0.0 --port 3000
8274EOF
8375
8476# Make entrypoint executable
8577RUN chmod +x /docker-entrypoint.sh
8678
87- # Expose port 80
88- EXPOSE 80
79+ # Expose port 3000 (Vite preview default)
80+ EXPOSE 3000
8981
90- # Simple health check for EasyPanel
91- HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD wget --no-verbose --tries=1 --spider http://localhost/health || exit 1
82+ # Health check for container monitoring
83+ HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=30s CMD wget --quiet --tries=1 --spider http://127.0.0.1:3000/ || exit 1
9284
9385# Set entrypoint
9486ENTRYPOINT ["/docker-entrypoint.sh" ]
0 commit comments