Add SPA static file serving from backend
Backend (Server.hs): - serveStaticOrSpa: serves static files from --static-dir - SPA fallback: extensionless paths serve index.html - MIME type mapping for html/css/js/png/svg/ico/woff2 Frontend: - ES module imports with import map for Mithril CDN - Build script: tsc + copy index.html + static assets CLI: - --static-dir flag (default: frontend/dist) - scripts/run passes through extra args - Dockerfile CMD points at /usr/local/share/sis/static
This commit is contained in:
+7
-5
@@ -1,19 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run the sis-server in Docker.
|
||||
#
|
||||
# Usage: ./scripts/run [--port PORT]
|
||||
# Usage: ./scripts/run [--port PORT] [--static-dir DIR] [-- ... extra server args]
|
||||
#
|
||||
# The server listens on port 8080 inside the container, mapped to PORT
|
||||
# on the host (default 8080). Pass --port to change the host-side port.
|
||||
# on the host (default 8080).
|
||||
#
|
||||
# Examples:
|
||||
# ./scripts/run
|
||||
# ./scripts/run --port 9090
|
||||
# ./scripts/run --static-dir frontend/dist
|
||||
set -euo pipefail
|
||||
|
||||
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
HOST_PORT=8080
|
||||
SERVER_ARGS=()
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--port)
|
||||
@@ -21,8 +23,8 @@ while [ $# -gt 0 ]; do
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1" >&2
|
||||
exit 1
|
||||
SERVER_ARGS+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@@ -40,4 +42,4 @@ exec docker run --rm -i $([ -t 0 ] && printf -- -t) \
|
||||
-w /work \
|
||||
-p "${HOST_PORT}:8080" \
|
||||
"${IMAGE}" \
|
||||
stack exec sis-server -- --port 8080
|
||||
stack exec sis-server -- --port 8080 "${SERVER_ARGS[@]}"
|
||||
|
||||
Reference in New Issue
Block a user