forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits

compose.yaml51 lines, 2.5 KiBHistoryRawDownload
1# The frontend: one container behind podman compose — Bun serves the built SPA
2# and reverse-proxies /api/* to the backend.
3#
4# Every default (BACKEND_ORIGIN, HOST, PORT) is written once, in the image's
5# ENV block (Containerfile); this file declares no `environment:` at all, so
6# nothing here can shadow a value. A laptop runs it as-is; a server overlays
7# ~/hezarfen_frontend/hezarfen_frontend.env (0600, written by hand from
8# deploy/hezarfen_frontend.env.example) through `env_file:`.
9#
10# `--env-file` only matters for `HEZARFEN_TAG` (the deploy passes the
11# deploy-owned stack.env second, so it wins for that one key); the container's
12# knobs arrive through `env_file:`, which needs no flag.
13#
14# Those values are read when the container STARTS: editing the file needs a
15# recreate (`podman compose up -d`, or `systemctl --user restart
16# hezarfen_frontend_compose`), not a `podman restart`.
17
18services:
19 frontend:
20 build:
21 context: .
22 dockerfile: Containerfile
23 # HEZARFEN_TAG comes from the deploy-owned stack.env (--env-file), or the
24 # latest local build on a laptop.
25 image: localhost/hezarfen_frontend:${HEZARFEN_TAG:-latest}
26 container_name: hezarfen_frontend
27 # Host networking, on purpose: the process then shares the host's loopback,
28 # so BACKEND_ORIGIN=http://127.0.0.1:7656 (the backend's published loopback
29 # port) is reachable from inside the container exactly as it would be from
30 # a host process — a bridge network would resolve 127.0.0.1 to the
31 # container itself and refuse the connection.
32 #
33 # There is no `ports:` mapping under host networking: the app binds the
34 # host's interface directly. Keep it off the LAN with HOST=127.0.0.1 in
35 # hezarfen_frontend.env (server.ts binds what HOST says, 0.0.0.0 by
36 # default), leaving the reverse proxy on the same loopback as the only door.
37 network_mode: host
38 env_file:
39 # Written once by the operator on the server (0600); absent on a laptop.
40 - path: hezarfen_frontend.env
41 required: false
42 restart: unless-stopped
43 healthcheck:
44 # Bun-based: the slim runtime image ships no curl. PORT comes from the
45 # container's own environment — the image ENV block is where the number
46 # lives, so this probe holds no second copy of it.
47 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))"]
48 interval: 30s
49 timeout: 5s
50 retries: 3
51 start_period: 10s