Fix problem with in-pod nginx.conf
Some checks failed
Podman Rootless Demo / test-backend (push) Has been skipped
Podman Rootless Demo / test-frontend (push) Has been skipped
Podman Rootless Demo / build-backend (push) Has been skipped
Podman Rootless Demo / build-frontend (push) Has been skipped
Podman Rootless Demo / deploy-prod (push) Failing after 19s

This commit is contained in:
continuist 2025-09-20 20:46:40 -04:00
parent 80f8f75208
commit 119555b291

View file

@ -245,20 +245,20 @@ jobs:
podman --remote pull "$REGISTRY_HOST/$APP_NAME/sharenet-backend-api-postgres:$IMAGE_TAG"
podman --remote pull "$REGISTRY_HOST/$APP_NAME/sharenet-frontend:$IMAGE_TAG"
- name: Prepare in-pod nginx config on host
- name: Render nginx.conf and put on host (no unshare)
run: |
set -euo pipefail
# create dir on host (via user namespace)
podman --remote unshare mkdir -p /opt/sharenet/nginx /opt/sharenet/volumes/nginx-cache
# render temp config (inside the job container)
apk add --no-cache gettext >/dev/null
apk add --no-cache gettext >/dev/null # envsubst
# Render template locally in the job container
envsubst < nginx/nginx.conf > /tmp/nginx.conf
# write it onto the host
podman --remote unshare sh -c 'cat > /opt/sharenet/nginx/nginx.conf' < /tmp/nginx.conf
# reasonable perms for rootless mount
podman --remote unshare chown -R 1001:1001 /opt/sharenet
podman --remote unshare chmod 0755 /opt/sharenet /opt/sharenet/nginx /opt/sharenet/volumes /opt/sharenet/volumes/nginx-cache
podman --remote unshare chmod 0644 /opt/sharenet/nginx/nginx.conf || true
# Write it to the host via a remote Podman helper container.
# Run as uid:gid 1001:1001 so writes match prod-services ownership.
podman --remote run --rm -i \
--user 1001:1001 \
-v /opt/sharenet/nginx:/host-nginx:rw \
alpine:3.20 sh -c 'install -D -m 0644 /dev/stdin /host-nginx/nginx.conf' \
< /tmp/nginx.conf
- name: Install envsubst (Alpine)
run: apk add --no-cache gettext