# The frontend: one container behind podman compose — Bun serves the built SPA # and reverse-proxies /api/* to the backend. # # Every default (BACKEND_ORIGIN, HOST, PORT) is written once, in the image's # ENV block (Containerfile); this file declares no `environment:` at all, so # nothing here can shadow a value. A laptop runs it as-is; a server overlays # ~/hezarfen_frontend/hezarfen_frontend.env (0600, written by hand from # deploy/hezarfen_frontend.env.example) through `env_file:`. # # `--env-file` only matters for `HEZARFEN_TAG` (the deploy passes the # deploy-owned stack.env second, so it wins for that one key); the container's # knobs arrive through `env_file:`, which needs no flag. # # Those values are read when the container STARTS: editing the file needs a # recreate (`podman compose up -d`, or `systemctl --user restart # hezarfen_frontend_compose`), not a `podman restart`. services: frontend: build: context: . dockerfile: Containerfile # HEZARFEN_TAG comes from the deploy-owned stack.env (--env-file), or the # latest local build on a laptop. image: localhost/hezarfen_frontend:${HEZARFEN_TAG:-latest} container_name: hezarfen_frontend # Host networking, on purpose: the process then shares the host's loopback, # so BACKEND_ORIGIN=http://127.0.0.1:7656 (the backend's published loopback # port) is reachable from inside the container exactly as it would be from # a host process — a bridge network would resolve 127.0.0.1 to the # container itself and refuse the connection. # # There is no `ports:` mapping under host networking: the app binds the # host's interface directly. Keep it off the LAN with HOST=127.0.0.1 in # hezarfen_frontend.env (server.ts binds what HOST says, 0.0.0.0 by # default), leaving the reverse proxy on the same loopback as the only door. network_mode: host env_file: # Written once by the operator on the server (0600); absent on a laptop. - path: hezarfen_frontend.env required: false restart: unless-stopped healthcheck: # Bun-based: the slim runtime image ships no curl. PORT comes from the # container's own environment — the image ENV block is where the number # lives, so this probe holds no second copy of it. test: ["CMD", "bun", "-e", "fetch('http://127.0.0.1:'+Bun.env.PORT+'/').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"] interval: 30s timeout: 5s retries: 3 start_period: 10s