Files
kmtnflower/docker-entrypoint.sh
DevOps QA 89cac854ae
CI Pipeline / backend-test (push) Successful in 5m1s
CI Pipeline / frontend-test (push) Successful in 29s
CI Pipeline / frontend-build (push) Successful in 30s
CI Pipeline / backend-lint (push) Successful in 10s
CI Pipeline / backend-test (pull_request) Successful in 4m48s
CI Pipeline / frontend-test (pull_request) Successful in 24s
CI Pipeline / frontend-build (pull_request) Successful in 30s
CI Pipeline / backend-lint (pull_request) Successful in 10s
CI Pipeline / quality-gate (push) Successful in 2s
CI Pipeline / quality-gate (pull_request) Successful in 2s
fix: use full nginx.conf instead of conf.d snippet to avoid directive nesting error
Alpine nginx includes conf.d/*.conf inside the http{} block, but our
template contained map/log_format directives and a server{} block that
conflicted with the include structure. Switched to a complete standalone
nginx.conf with proper user/events/http nesting.
2026-08-07 14:47:48 +00:00

37 lines
1.5 KiB
Bash

#!/bin/sh
# Start the Angular SSR Node process, then nginx.
set -e
# Ensure nginx can write to the shared logs directory
mkdir -p /logs && chown nginx:nginx /logs
# Render nginx config from template to /etc/nginx/nginx.conf
# (full config, not conf.d/ snippet — avoids Alpine include nesting issues)
sed "s|__API_UPSTREAM__|${API_UPSTREAM}|g" /etc/nginx/conf.d/nginx.conf.template > /etc/nginx/nginx.conf
# Render client-side config.json for fallback use
envsubst '${API_PUBLIC_URL}' < /usr/share/nginx/html/config.json.template > /usr/share/nginx/html/config.json
# Start the Angular SSR server (Node process) in the background
# Point at nginx (port 80) so SSR API calls go through the nginx proxy chain
# to the upstream backend. Nginx is started after SSR so the chain is complete
# by the time the first SSR request actually needs API data.
export SSR_API_BASE_URL="http://localhost:80"
echo "[entrypoint] Starting Angular SSR server on port 4200..."
node /app/server/server.mjs &
SSR_PID=$!
# Wait for the SSR server to be ready (up to 10 seconds)
echo "[entrypoint] Waiting for SSR server to be ready..."
for i in $(seq 1 20); do
if node -e "require('http').get('http://localhost:4200/', (r) => { process.exit(r.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))" 2>/dev/null; then
echo "[entrypoint] SSR server is ready."
break
fi
sleep 0.5
done
# Start nginx in the foreground (primary process)
echo "[entrypoint] Starting nginx..."
exec nginx -g 'daemon off;'