Spaces:
No application file
No application file
File size: 1,126 Bytes
7864fb7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #!/bin/bash
set -euo pipefail
# ---------------------------------------------------------------------------
# Process graph:
#
# client -> nginx (:7860) -> key agent (:5001) -> upstream (:5000)
#
# nginx holds no secret. The key agent resolves the key into memory at
# startup and attaches it on the way through. Nothing is written to disk.
# ---------------------------------------------------------------------------
echo "[entrypoint] starting demo upstream on :5000"
python3 /opt/demo_upstream.py &
echo "[entrypoint] starting key agent on :5001"
python3 /opt/key_agent.py &
AGENT_PID=$!
# Wait for the agent to accept connections before nginx starts proxying.
for _ in $(seq 1 30); do
if (exec 3<>/dev/tcp/127.0.0.1/5001) 2>/dev/null; then
exec 3<&- 3>&-
echo "[entrypoint] key agent is up"
break
fi
sleep 0.5
done
if ! kill -0 "$AGENT_PID" 2>/dev/null; then
echo "[entrypoint][fatal] key agent exited" >&2
exit 1
fi
echo "[entrypoint] validating nginx config"
/usr/local/nginx/sbin/nginx -t
echo "[entrypoint] starting nginx in foreground"
exec /usr/local/nginx/sbin/nginx -g 'daemon off;'
|