entrypoint.sh 2.5 KiB 69 lines Raw
1 #!/bin/sh2 # hu13 container entrypoint (f0rge issue #11): build once, then serve.3 #4 # Layout: the repo is mounted read-only at /data/repo, the inbox lives at5 # /data/inbox (OUTSIDE the served tree — serve refuses to start otherwise),6 # the built site goes to /srv/www.7 #8 # Env:9 #   HU13_BRANCH     branch to build (default: main/master auto-detect)10 #   HU13_CLONE_URL  clone URL to advertise (default: repo origin remote)11 #   HU13_PUBLIC_ORIGIN public base URL of this server (default: unset;12 #                   when set, clone block advertises `<origin>/repo.git`)13 #   HU13_REPO_NAME  repo display name (default: repo dir name; never blank)14 #   HU13_DESCRIPTION15 #                   site description (default: hidden, no empty <p>)16 #   HU13_LISTEN     serve address (default: 0.0.0.0:39313)17 #   HU13_MAX_TITLE / HU13_MAX_BODY / HU13_MAX_BYTES /18 #   HU13_RATE_PER_HOUR / HU13_QUOTA19 #                   inbox caps (serve defaults when unset; passed through20 #                   as flags only when set, env is the fallback otherwise)21 #22 # Fail loud: any build failure (bad branch, bad repo, missing dir)23 # aborts before serve starts. `serve` is exec'd so it keeps PID 1.24 set -eu25 26 # Mounted checkouts belong to the host uid, but we run as uid 10000:27 # without this git refuses every read ("dubious ownership") and the28 # build below would misreport "branch not found".29 git config --global --add safe.directory /data/repo30 31 # Build argv with "$@" (POSIX-safe: values with spaces/quotes survive).32 set -- /data/repo -o /srv/www33 if [ -n "${HU13_BRANCH:-}" ]; then34     set -- "$@" --branch "$HU13_BRANCH"35 fi36 if [ -n "${HU13_CLONE_URL:-}" ]; then37     set -- "$@" --clone-url "$HU13_CLONE_URL"38 fi39 if [ -n "${HU13_PUBLIC_ORIGIN:-}" ]; then40     set -- "$@" --public-origin "$HU13_PUBLIC_ORIGIN"41 fi42 if [ -n "${HU13_REPO_NAME:-}" ]; then43     set -- "$@" --repo-name "$HU13_REPO_NAME"44 fi45 if [ -n "${HU13_DESCRIPTION:-}" ]; then46     set -- "$@" --description "$HU13_DESCRIPTION"47 fi48 hu13 build "$@"49 50 set -- --www /srv/www --inbox-dir /data/inbox \51     --listen "${HU13_LISTEN:-0.0.0.0:39313}"52 53 if [ -n "${HU13_MAX_TITLE:-}" ]; then54     set -- "$@" --max-title "$HU13_MAX_TITLE"55 fi56 if [ -n "${HU13_MAX_BODY:-}" ]; then57     set -- "$@" --max-body "$HU13_MAX_BODY"58 fi59 if [ -n "${HU13_MAX_BYTES:-}" ]; then60     set -- "$@" --max-bytes "$HU13_MAX_BYTES"61 fi62 if [ -n "${HU13_RATE_PER_HOUR:-}" ]; then63     set -- "$@" --rate-per-hour "$HU13_RATE_PER_HOUR"64 fi65 if [ -n "${HU13_QUOTA:-}" ]; then66     set -- "$@" --quota "$HU13_QUOTA"67 fi68 69 exec hu13 serve "$@"