Fix here-document syntax issues in runtime config generation and Go module setup for mock API server
This commit is contained in:
		
							
								
								
									
										467
									
								
								start.sh
									
									
									
									
									
								
							
							
						
						
									
										467
									
								
								start.sh
									
									
									
									
									
								
							| @@ -1066,16 +1066,18 @@ else | |||||||
|     echo "==> ERROR: Museum server not found" |     echo "==> ERROR: Museum server not found" | ||||||
|     echo "==> Starting a mock server" |     echo "==> Starting a mock server" | ||||||
|      |      | ||||||
|     # Create a temporary directory for a simple Go server |     # Create a temporary directory for a simple Go server with correct permissions | ||||||
|     mkdir -p /tmp/mock-server |     mkdir -p /tmp/mock-server | ||||||
|     cd /tmp/mock-server |     cd /tmp/mock-server | ||||||
|      |      | ||||||
|     # Initialize a proper Go module |     # Create a simple Go module setup | ||||||
|     echo "==> Initializing Go module for mock API server" |     echo "==> Creating proper Go module structure" | ||||||
|     go mod init mock-server |     touch go.mod | ||||||
|  |     echo "module mock-server" > go.mod | ||||||
|      |      | ||||||
|     # Write the program to a file with proper quoting |     # Write main.go correctly | ||||||
|     cat > main.go << 'GOMOCK' |     echo "==> Writing main.go for mock API server" | ||||||
|  |     cat > main.go << EOF | ||||||
| package main | package main | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| @@ -1454,7 +1456,7 @@ func main() { | |||||||
|         logger.Fatalf("Server failed: %v", err) |         logger.Fatalf("Server failed: %v", err) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| GOMOCK | EOF | ||||||
|      |      | ||||||
|     # Completely unset Go module-related environment variables  |     # Completely unset Go module-related environment variables  | ||||||
|     echo "==> Unsetting module flags before building mock server" |     echo "==> Unsetting module flags before building mock server" | ||||||
| @@ -1463,24 +1465,23 @@ GOMOCK | |||||||
|     unset GOMODCACHE |     unset GOMODCACHE | ||||||
|     unset GOPATH |     unset GOPATH | ||||||
|      |      | ||||||
|     # Build and run the mock server in the background |     # Show directory content for debugging | ||||||
|     echo "==> Building and starting mock API server on port 8080" |     echo "==> Current directory contents:" | ||||||
|     ls -la |     ls -la | ||||||
|      |      | ||||||
|     # Show go.mod for debugging |     # Build and run the mock server in the background | ||||||
|     echo "==> Go module file contents:" |     echo "==> Building and starting mock API server on port 8080" | ||||||
|     cat go.mod |  | ||||||
|      |      | ||||||
|     # Build the mock server (explicitly in current directory) |     # Build without specifying the file (shorter command) | ||||||
|     if go build -o mock_server .; then |     if go build -v .; then | ||||||
|         echo "==> Successfully compiled mock API server" |         echo "==> Successfully compiled mock API server" | ||||||
|          |          | ||||||
|         # Create log directory if it doesn't exist |         # Create log directory if it doesn't exist | ||||||
|         mkdir -p /app/data/logs |         mkdir -p /app/data/logs | ||||||
|          |          | ||||||
|         # Start the server and log both to file and to console |         # Start the server and log both to file and to console | ||||||
|         chmod +x ./mock_server |         chmod +x ./mock-server | ||||||
|         nohup ./mock_server > /app/data/logs/mock_server.log 2>&1 & |         nohup ./mock-server > /app/data/logs/mock_server.log 2>&1 & | ||||||
|         SERVER_PID=$! |         SERVER_PID=$! | ||||||
|         echo "==> Mock API server started with PID $SERVER_PID" |         echo "==> Mock API server started with PID $SERVER_PID" | ||||||
|          |          | ||||||
| @@ -1877,34 +1878,34 @@ EOT | |||||||
|     # Create runtime-config.js files in writable locations |     # Create runtime-config.js files in writable locations | ||||||
|     echo "==> Creating runtime-config.js in writable location" |     echo "==> Creating runtime-config.js in writable location" | ||||||
|     mkdir -p /app/data/web |     mkdir -p /app/data/web | ||||||
|     cat > /app/data/web/runtime-config.js << 'EOT' |     cat << EOF > /app/data/web/runtime-config.js | ||||||
|     // Runtime configuration for Ente | // Runtime configuration for Ente | ||||||
|     window.ENTE_CONFIG = { | window.ENTE_CONFIG = { | ||||||
|         API_URL: '${API_ENDPOINT}', |     API_URL: '${API_ENDPOINT}', | ||||||
|         PUBLIC_ALBUMS_URL: '${CLOUDRON_APP_ORIGIN}/public' |     PUBLIC_ALBUMS_URL: '${CLOUDRON_APP_ORIGIN}/public' | ||||||
|     }; | }; | ||||||
|  |  | ||||||
|     // Next.js environment variables | // Next.js environment variables | ||||||
|     window.process = window.process || {}; | window.process = window.process || {}; | ||||||
|     window.process.env = window.process.env || {}; | window.process.env = window.process.env || {}; | ||||||
|     window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = '${API_ENDPOINT}'; | window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = '${API_ENDPOINT}'; | ||||||
|     window.process.env.NEXT_PUBLIC_ENTE_PUBLIC_ALBUMS_ENDPOINT = '${CLOUDRON_APP_ORIGIN}/public'; | window.process.env.NEXT_PUBLIC_ENTE_PUBLIC_ALBUMS_ENDPOINT = '${CLOUDRON_APP_ORIGIN}/public'; | ||||||
|     window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT = '${API_ENDPOINT}'; | window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT = '${API_ENDPOINT}'; | ||||||
|     window.process.env.REACT_APP_ENTE_ENDPOINT = '${API_ENDPOINT}'; | window.process.env.REACT_APP_ENTE_ENDPOINT = '${API_ENDPOINT}'; | ||||||
|  |  | ||||||
|     // Make sure all URLs are properly formatted for URL constructor | // Make sure all URLs are properly formatted for URL constructor | ||||||
|     if (!window.ENTE_CONFIG.API_URL.startsWith('http')) { | if (!window.ENTE_CONFIG.API_URL.startsWith('http')) { | ||||||
|         console.log('Adding https:// prefix to API_URL'); |     console.log('Adding https:// prefix to API_URL'); | ||||||
|         window.ENTE_CONFIG.API_URL = window.location.origin + window.ENTE_CONFIG.API_URL; |     window.ENTE_CONFIG.API_URL = window.location.origin + window.ENTE_CONFIG.API_URL; | ||||||
|         window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = window.location.origin + window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT; |     window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = window.location.origin + window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT; | ||||||
|         window.process.env.REACT_APP_ENTE_ENDPOINT = window.location.origin + window.process.env.REACT_APP_ENTE_ENDPOINT; |     window.process.env.REACT_APP_ENTE_ENDPOINT = window.location.origin + window.process.env.REACT_APP_ENTE_ENDPOINT; | ||||||
|         window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT = window.location.origin + window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT; |     window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT = window.location.origin + window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT; | ||||||
|     } | } | ||||||
|  |  | ||||||
|     console.log('Ente runtime config loaded from runtime-config.js'); | console.log('Ente runtime config loaded from runtime-config.js'); | ||||||
|     console.log('API_URL:', window.ENTE_CONFIG.API_URL); | console.log('API_URL:', window.ENTE_CONFIG.API_URL); | ||||||
|     console.log('PUBLIC_ALBUMS_URL:', window.ENTE_CONFIG.PUBLIC_ALBUMS_URL); | console.log('PUBLIC_ALBUMS_URL:', window.ENTE_CONFIG.PUBLIC_ALBUMS_URL); | ||||||
|     EOT | EOF | ||||||
|  |  | ||||||
|     # Update the variables in the runtime config |     # Update the variables in the runtime config | ||||||
|     sed -i "s|\${API_ENDPOINT}|${API_ENDPOINT}|g" /app/data/web/runtime-config.js |     sed -i "s|\${API_ENDPOINT}|${API_ENDPOINT}|g" /app/data/web/runtime-config.js | ||||||
| @@ -1954,214 +1955,214 @@ HTML | |||||||
|     done |     done | ||||||
|  |  | ||||||
|     # Modify the Caddyfile to serve our modified HTML files |     # Modify the Caddyfile to serve our modified HTML files | ||||||
|     cat > /app/data/caddy/Caddyfile <<EOT |     cat << EOF > /app/data/caddy/Caddyfile | ||||||
|     # Global settings | # Global settings | ||||||
|     { | { | ||||||
|         admin off |     admin off | ||||||
|         auto_https off |     auto_https off | ||||||
|         http_port $CADDY_PORT |     http_port $CADDY_PORT | ||||||
|         https_port 0 |     https_port 0 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # Main site configuration | ||||||
|  | :$CADDY_PORT { | ||||||
|  |     # Basic logging | ||||||
|  |     log { | ||||||
|  |         level INFO | ||||||
|  |         output file /app/data/logs/caddy.log | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     # Main site configuration |     # Configuration scripts - directly served | ||||||
|     :$CADDY_PORT { |     handle /config.js { | ||||||
|         # Basic logging |         header Content-Type application/javascript | ||||||
|         log { |         respond " | ||||||
|             level INFO |             // Direct configuration for Ente | ||||||
|             output file /app/data/logs/caddy.log |             window.ENTE_CONFIG = { | ||||||
|         } |                 API_URL: '${API_ENDPOINT}', | ||||||
|  |                 PUBLIC_ALBUMS_URL: '${CLOUDRON_APP_ORIGIN}/public' | ||||||
|  |             }; | ||||||
|              |              | ||||||
|         # Configuration scripts - directly served |             // Next.js environment variables | ||||||
|         handle /config.js { |             window.process = window.process || {}; | ||||||
|             header Content-Type application/javascript |             window.process.env = window.process.env || {}; | ||||||
|             respond " |             window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = '${API_ENDPOINT}'; | ||||||
|                 // Direct configuration for Ente |             window.process.env.NEXT_PUBLIC_ENTE_PUBLIC_ALBUMS_ENDPOINT = '${CLOUDRON_APP_ORIGIN}/public'; | ||||||
|                 window.ENTE_CONFIG = { |             window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT = '${API_ENDPOINT}'; | ||||||
|                     API_URL: '${API_ENDPOINT}', |             window.process.env.REACT_APP_ENTE_ENDPOINT = '${API_ENDPOINT}'; | ||||||
|                     PUBLIC_ALBUMS_URL: '${CLOUDRON_APP_ORIGIN}/public' |  | ||||||
|                 }; |  | ||||||
|              |              | ||||||
|                 // Next.js environment variables |             // Make sure all URLs are properly formatted for URL constructor | ||||||
|                 window.process = window.process || {}; |             if (!window.ENTE_CONFIG.API_URL.startsWith('http')) { | ||||||
|                 window.process.env = window.process.env || {}; |                 console.log('Adding https:// prefix to API_URL'); | ||||||
|                 window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = '${API_ENDPOINT}'; |                 window.ENTE_CONFIG.API_URL = window.location.origin + window.ENTE_CONFIG.API_URL; | ||||||
|                 window.process.env.NEXT_PUBLIC_ENTE_PUBLIC_ALBUMS_ENDPOINT = '${CLOUDRON_APP_ORIGIN}/public'; |                 window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = window.location.origin + window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT; | ||||||
|                 window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT = '${API_ENDPOINT}'; |                 window.process.env.REACT_APP_ENTE_ENDPOINT = window.location.origin + window.process.env.REACT_APP_ENTE_ENDPOINT; | ||||||
|                 window.process.env.REACT_APP_ENTE_ENDPOINT = '${API_ENDPOINT}'; |                 window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT = window.location.origin + window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT; | ||||||
|  |             } | ||||||
|              |              | ||||||
|                 // Make sure all URLs are properly formatted for URL constructor |             console.log('Ente config loaded - API_URL:', window.ENTE_CONFIG.API_URL); | ||||||
|                 if (!window.ENTE_CONFIG.API_URL.startsWith('http')) { |             console.log('Ente config loaded - PUBLIC_ALBUMS_URL:', window.ENTE_CONFIG.PUBLIC_ALBUMS_URL); | ||||||
|                     console.log('Adding https:// prefix to API_URL'); |         " | ||||||
|                     window.ENTE_CONFIG.API_URL = window.location.origin + window.ENTE_CONFIG.API_URL; |     } | ||||||
|                     window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = window.location.origin + window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT; |  | ||||||
|                     window.process.env.REACT_APP_ENTE_ENDPOINT = window.location.origin + window.process.env.REACT_APP_ENTE_ENDPOINT; |  | ||||||
|                     window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT = window.location.origin + window.process.env.NEXT_PUBLIC_REACT_APP_ENTE_ENDPOINT; |  | ||||||
|                 } |  | ||||||
|      |      | ||||||
|                 console.log('Ente config loaded - API_URL:', window.ENTE_CONFIG.API_URL); |     handle /runtime-config.js { | ||||||
|                 console.log('Ente config loaded - PUBLIC_ALBUMS_URL:', window.ENTE_CONFIG.PUBLIC_ALBUMS_URL); |         root * /app/data/web | ||||||
|             " |         file_server | ||||||
|         } |     } | ||||||
|      |      | ||||||
|         handle /runtime-config.js { |     # Root path serves the photos app | ||||||
|             root * /app/data/web |     handle / { | ||||||
|  |         # Special handling for index.html | ||||||
|  |         @is_index path / | ||||||
|  |         handle @is_index { | ||||||
|  |             root * /app/data/web/photos | ||||||
|  |             try_files {path} /index.html | ||||||
|             file_server |             file_server | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         # Root path serves the photos app |         # Serve other static files from the original location | ||||||
|         handle / { |         @not_index { | ||||||
|             # Special handling for index.html |             not path / | ||||||
|             @is_index path / |             not path /api/* | ||||||
|             handle @is_index { |             not path /public/* | ||||||
|                 root * /app/data/web/photos |             not path /accounts/* | ||||||
|                 try_files {path} /index.html |             not path /auth/* | ||||||
|                 file_server |             not path /cast/* | ||||||
|             } |  | ||||||
|              |  | ||||||
|             # Serve other static files from the original location |  | ||||||
|             @not_index { |  | ||||||
|                 not path / |  | ||||||
|                 not path /api/* |  | ||||||
|                 not path /public/* |  | ||||||
|                 not path /accounts/* |  | ||||||
|                 not path /auth/* |  | ||||||
|                 not path /cast/* |  | ||||||
|             } |  | ||||||
|             handle @not_index { |  | ||||||
|                 root * /app/web/photos |  | ||||||
|                 try_files {path} /index.html |  | ||||||
|                 file_server |  | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|          |         handle @not_index { | ||||||
|         # Next.js static files |  | ||||||
|         handle /_next/* { |  | ||||||
|             root * /app/web/photos |             root * /app/web/photos | ||||||
|             file_server |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         # Add global headers for common file types |  | ||||||
|         header /*.js Content-Type application/javascript |  | ||||||
|         header /*.css Content-Type text/css |  | ||||||
|         header /*.json Content-Type application/json |  | ||||||
|         header /*.svg Content-Type image/svg+xml |  | ||||||
|         header /*.woff2 Content-Type font/woff2 |  | ||||||
|         header /_next/static/chunks/*.js Content-Type application/javascript |  | ||||||
|         header /_next/static/css/*.css Content-Type text/css |  | ||||||
|  |  | ||||||
|         # Accounts app |  | ||||||
|         handle /accounts { |  | ||||||
|             root * /app/data/web/accounts |  | ||||||
|             try_files {path} /index.html |             try_files {path} /index.html | ||||||
|             file_server |             file_server | ||||||
|         } |         } | ||||||
|          |  | ||||||
|         handle /accounts/* { |  | ||||||
|             @is_index path /accounts/ /accounts/index.html |  | ||||||
|             handle @is_index { |  | ||||||
|                 root * /app/data/web |  | ||||||
|                 try_files /accounts/index.html |  | ||||||
|                 file_server |  | ||||||
|             } |  | ||||||
|              |  | ||||||
|             @not_index { |  | ||||||
|                 not path /accounts/ |  | ||||||
|                 not path /accounts/index.html |  | ||||||
|             } |  | ||||||
|             handle @not_index { |  | ||||||
|                 uri strip_prefix /accounts |  | ||||||
|                 root * /app/web/accounts |  | ||||||
|                 try_files {path} /index.html |  | ||||||
|                 file_server |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         # Auth app |  | ||||||
|         handle /auth { |  | ||||||
|             root * /app/data/web/auth |  | ||||||
|             try_files {path} /index.html |  | ||||||
|             file_server |  | ||||||
|         } |  | ||||||
|          |  | ||||||
|         handle /auth/* { |  | ||||||
|             @is_index path /auth/ /auth/index.html |  | ||||||
|             handle @is_index { |  | ||||||
|                 root * /app/data/web |  | ||||||
|                 try_files /auth/index.html |  | ||||||
|                 file_server |  | ||||||
|             } |  | ||||||
|              |  | ||||||
|             @not_index { |  | ||||||
|                 not path /auth/ |  | ||||||
|                 not path /auth/index.html |  | ||||||
|             } |  | ||||||
|             handle @not_index { |  | ||||||
|                 uri strip_prefix /auth |  | ||||||
|                 root * /app/web/auth |  | ||||||
|                 try_files {path} /index.html |  | ||||||
|                 file_server |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         # Cast app |  | ||||||
|         handle /cast { |  | ||||||
|             root * /app/data/web/cast |  | ||||||
|             try_files {path} /index.html |  | ||||||
|             file_server |  | ||||||
|         } |  | ||||||
|          |  | ||||||
|         handle /cast/* { |  | ||||||
|             @is_index path /cast/ /cast/index.html |  | ||||||
|             handle @is_index { |  | ||||||
|                 root * /app/data/web |  | ||||||
|                 try_files /cast/index.html |  | ||||||
|                 file_server |  | ||||||
|             } |  | ||||||
|              |  | ||||||
|             @not_index { |  | ||||||
|                 not path /cast/ |  | ||||||
|                 not path /cast/index.html |  | ||||||
|             } |  | ||||||
|             handle @not_index { |  | ||||||
|                 uri strip_prefix /cast |  | ||||||
|                 root * /app/web/cast |  | ||||||
|                 try_files {path} /index.html |  | ||||||
|                 file_server |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         # Main API proxy |  | ||||||
|         handle /api/* { |  | ||||||
|             uri strip_prefix /api |  | ||||||
|             reverse_proxy 0.0.0.0:$API_PORT |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         # Public albums API proxy |  | ||||||
|         handle /public/* { |  | ||||||
|             uri strip_prefix /public |  | ||||||
|             reverse_proxy 0.0.0.0:$PUBLIC_ALBUMS_PORT |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         # Health check endpoints |  | ||||||
|         handle /health { |  | ||||||
|             respond "OK" |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         handle /healthcheck { |  | ||||||
|             respond "OK" |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         handle /api/health { |  | ||||||
|             uri strip_prefix /api |  | ||||||
|             reverse_proxy 0.0.0.0:$API_PORT |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         handle /public/health { |  | ||||||
|             uri strip_prefix /public |  | ||||||
|             reverse_proxy 0.0.0.0:$PUBLIC_ALBUMS_PORT |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
|     EOT |      | ||||||
|  |     # Next.js static files | ||||||
|  |     handle /_next/* { | ||||||
|  |         root * /app/web/photos | ||||||
|  |         file_server | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     # Add global headers for common file types | ||||||
|  |     header /*.js Content-Type application/javascript | ||||||
|  |     header /*.css Content-Type text/css | ||||||
|  |     header /*.json Content-Type application/json | ||||||
|  |     header /*.svg Content-Type image/svg+xml | ||||||
|  |     header /*.woff2 Content-Type font/woff2 | ||||||
|  |     header /_next/static/chunks/*.js Content-Type application/javascript | ||||||
|  |     header /_next/static/css/*.css Content-Type text/css | ||||||
|  |  | ||||||
|  |     # Accounts app | ||||||
|  |     handle /accounts { | ||||||
|  |         root * /app/data/web/accounts | ||||||
|  |         try_files {path} /index.html | ||||||
|  |         file_server | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     handle /accounts/* { | ||||||
|  |         @is_index path /accounts/ /accounts/index.html | ||||||
|  |         handle @is_index { | ||||||
|  |             root * /app/data/web | ||||||
|  |             try_files /accounts/index.html | ||||||
|  |             file_server | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         @not_index { | ||||||
|  |             not path /accounts/ | ||||||
|  |             not path /accounts/index.html | ||||||
|  |         } | ||||||
|  |         handle @not_index { | ||||||
|  |             uri strip_prefix /accounts | ||||||
|  |             root * /app/web/accounts | ||||||
|  |             try_files {path} /index.html | ||||||
|  |             file_server | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     # Auth app | ||||||
|  |     handle /auth { | ||||||
|  |         root * /app/data/web/auth | ||||||
|  |         try_files {path} /index.html | ||||||
|  |         file_server | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     handle /auth/* { | ||||||
|  |         @is_index path /auth/ /auth/index.html | ||||||
|  |         handle @is_index { | ||||||
|  |             root * /app/data/web | ||||||
|  |             try_files /auth/index.html | ||||||
|  |             file_server | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         @not_index { | ||||||
|  |             not path /auth/ | ||||||
|  |             not path /auth/index.html | ||||||
|  |         } | ||||||
|  |         handle @not_index { | ||||||
|  |             uri strip_prefix /auth | ||||||
|  |             root * /app/web/auth | ||||||
|  |             try_files {path} /index.html | ||||||
|  |             file_server | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     # Cast app | ||||||
|  |     handle /cast { | ||||||
|  |         root * /app/data/web/cast | ||||||
|  |         try_files {path} /index.html | ||||||
|  |         file_server | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     handle /cast/* { | ||||||
|  |         @is_index path /cast/ /cast/index.html | ||||||
|  |         handle @is_index { | ||||||
|  |             root * /app/data/web | ||||||
|  |             try_files /cast/index.html | ||||||
|  |             file_server | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         @not_index { | ||||||
|  |             not path /cast/ | ||||||
|  |             not path /cast/index.html | ||||||
|  |         } | ||||||
|  |         handle @not_index { | ||||||
|  |             uri strip_prefix /cast | ||||||
|  |             root * /app/web/cast | ||||||
|  |             try_files {path} /index.html | ||||||
|  |             file_server | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     # Main API proxy | ||||||
|  |     handle /api/* { | ||||||
|  |         uri strip_prefix /api | ||||||
|  |         reverse_proxy 0.0.0.0:$API_PORT | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     # Public albums API proxy | ||||||
|  |     handle /public/* { | ||||||
|  |         uri strip_prefix /public | ||||||
|  |         reverse_proxy 0.0.0.0:$PUBLIC_ALBUMS_PORT | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     # Health check endpoints | ||||||
|  |     handle /health { | ||||||
|  |         respond "OK" | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     handle /healthcheck { | ||||||
|  |         respond "OK" | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     handle /api/health { | ||||||
|  |         uri strip_prefix /api | ||||||
|  |         reverse_proxy 0.0.0.0:$API_PORT | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     handle /public/health { | ||||||
|  |         uri strip_prefix /public | ||||||
|  |         reverse_proxy 0.0.0.0:$PUBLIC_ALBUMS_PORT | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | EOF | ||||||
|  |  | ||||||
|     echo "==> Created Caddy config with properly modified HTML files at /app/data/caddy/Caddyfile" |     echo "==> Created Caddy config with properly modified HTML files at /app/data/caddy/Caddyfile" | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user