mirror of
https://github.com/dpup/meshstream.git
synced 2026-03-28 17:42:37 +01:00
Static file fallback for entry pages in prod
This commit is contained in:
@@ -30,14 +30,22 @@ if ! command -v docker &> /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Building Docker image for Meshstream..."
|
||||
docker build \
|
||||
# Check if Docker Buildx is available
|
||||
if ! docker buildx version &> /dev/null; then
|
||||
echo "Error: Docker Buildx is not available. Please install or enable Docker Buildx."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Building Docker image for Meshstream using buildx (linux/amd64 platform)..."
|
||||
docker buildx build \
|
||||
--platform linux/amd64 \
|
||||
--build-arg MESHSTREAM_API_BASE_URL="${MESHSTREAM_API_BASE_URL:-}" \
|
||||
--build-arg MESHSTREAM_APP_ENV="${MESHSTREAM_APP_ENV:-production}" \
|
||||
--build-arg MESHSTREAM_SITE_TITLE="${MESHSTREAM_SITE_TITLE:-Bay Area Mesh}" \
|
||||
--build-arg MESHSTREAM_SITE_DESCRIPTION="${MESHSTREAM_SITE_DESCRIPTION:-Meshtastic activity in the Bay Area region, CA.}" \
|
||||
--build-arg MESHSTREAM_GOOGLE_MAPS_ID="${MESHSTREAM_GOOGLE_MAPS_ID}" \
|
||||
--build-arg MESHSTREAM_GOOGLE_MAPS_API_KEY="${MESHSTREAM_GOOGLE_MAPS_API_KEY}" \
|
||||
--load \
|
||||
-t meshstream:${IMAGE_TAG} .
|
||||
|
||||
echo "Tagging image for ECR repository..."
|
||||
|
||||
@@ -83,7 +83,8 @@ func (s *Server) Start() error {
|
||||
prefab.WithPort(port),
|
||||
prefab.WithHTTPHandlerFunc("/api/status", s.handleStatus),
|
||||
prefab.WithHTTPHandlerFunc("/api/stream", s.handleStream),
|
||||
prefab.WithStaticFiles("/", s.config.StaticDir),
|
||||
prefab.WithStaticFiles("/assets", s.config.StaticDir+"/assets"),
|
||||
prefab.WithHTTPHandlerFunc("/", s.fallbackHandler),
|
||||
)
|
||||
|
||||
// Start the server
|
||||
@@ -124,6 +125,14 @@ func (s *Server) handleStatus(w http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(w).Encode(status)
|
||||
}
|
||||
|
||||
func (s *Server) fallbackHandler(w http.ResponseWriter, r *http.Request) {
|
||||
logger := s.logger.Named("api.fallback")
|
||||
logger.Info("Fallback handler called")
|
||||
|
||||
// Serve the index.html file from the static directory
|
||||
http.ServeFile(w, r, s.config.StaticDir+"/index.html")
|
||||
}
|
||||
|
||||
// handleStream handles Server-Sent Events streaming of MQTT messages
|
||||
func (s *Server) handleStream(w http.ResponseWriter, r *http.Request) {
|
||||
logger := s.logger.Named("api.sse").With("remoteAddr", r.RemoteAddr)
|
||||
|
||||
@@ -115,29 +115,11 @@
|
||||
<div class="container">
|
||||
<h1>Meshstream</h1>
|
||||
|
||||
<div class="tabs">
|
||||
<div class="tab active" onclick="showView('simple')">Simple View</div>
|
||||
<div class="tab" onclick="showView('dev')">Development</div>
|
||||
</div>
|
||||
|
||||
<div id="simple-view" class="view active">
|
||||
<p>This page displays real-time messages from Meshtastic nodes via MQTT.</p>
|
||||
<div id="messages">
|
||||
<p>Waiting for messages...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="dev-view" class="view">
|
||||
<p>
|
||||
A web interface for viewing Meshtastic network traffic.
|
||||
This is a placeholder page for the production build.
|
||||
</p>
|
||||
<a href="http://localhost:3000" class="cta">Open Development Server</a>
|
||||
<p class="note">
|
||||
For production deployment, build the web application with <code>make web-build</code>
|
||||
to replace this placeholder with the full application.
|
||||
</p>
|
||||
<p>This page displays real-time messages from Meshtastic nodes via MQTT.</p>
|
||||
<div id="messages">
|
||||
<p>Waiting for messages...</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
Reference in New Issue
Block a user