fix produc domain name for the image creation

This commit is contained in:
root
2026-06-04 01:29:47 -04:00
parent 03f6c26940
commit 8d479b050d
2 changed files with 27 additions and 0 deletions
+16
View File
@@ -139,6 +139,22 @@ build_image:
- echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY_HOST" -u "$REGISTRY_USER" --password-stdin
script:
- echo "--- Building Docker Image ---"
- |
for var_name in NEXT_PUBLIC_API_URL NEXT_PUBLIC_MARKETPLACE_URL NEXT_PUBLIC_DASHBOARD_URL NEXT_PUBLIC_ADMIN_URL; do
var_value="$(printenv "$var_name" || true)"
if [ -z "$var_value" ]; then
echo "$var_name is not set. Refusing to build a production image with missing public frontend URLs." >&2
exit 1
fi
case "$var_value" in
*example.com*)
echo "$var_name=$var_value still uses the placeholder example.com domain. Update the GitLab CI/CD variable before building." >&2
exit 1
;;
esac
done
# NEXT_PUBLIC_* vars are inlined into Next.js bundles at build time — must be passed as ARGs
- |
docker build \
+11
View File
@@ -191,6 +191,17 @@ If you want GitLab CI to build once and deploy by pulling a prebuilt image on th
If `REGISTRY_*` variables are set, the CI pipeline now uses them as a complete override and requires all four values. If they are unset, the pipeline falls back to GitLab's `CI_REGISTRY_*` variables.
For production image builds, also define these GitLab CI/CD variables with their real public URLs:
```text
NEXT_PUBLIC_API_URL=https://api.rentaldrivego.ma/api/v1
NEXT_PUBLIC_MARKETPLACE_URL=https://rentaldrivego.ma
NEXT_PUBLIC_DASHBOARD_URL=https://rentaldrivego.ma/dashboard
NEXT_PUBLIC_ADMIN_URL=https://rentaldrivego.ma/admin
```
The Docker build now fails if any of those values are missing or still point at `example.com`, because Next.js inlines them into the production frontend bundles at build time.
Example explicit values for a local registry exposed through Traefik:
```text