From c0761149dcdee9f515b2cb3c1935494483e5487f Mon Sep 17 00:00:00 2001
From: Dominik Hebeler <dominik@suma-ev.de>
Date: Thu, 30 Nov 2023 15:35:36 +0100
Subject: [PATCH] fix fpm host

---
 .env                         | 9 +++++----
 .gitlab-ci.yml               | 1 +
 build/nginx/Dockerfile       | 4 +++-
 build/nginx/config/maps.conf | 2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/.env b/.env
index d24f952..a00b34c 100644
--- a/.env
+++ b/.env
@@ -1,11 +1,12 @@
 ENVIRONMENT=development # Environment to deploy to. Can be: development|production
 
-NODE_TAG=10
-COMPOSER_VERSION=2.6.5
-
 IMAGE_NAME=metagermaps
 IMAGE_TAG=dev
 
 # If you do not have user id 1000 on your local machine you can switch here to make sure permissions of dynamically created data match your current user
 USER_ID=1000   # User ID used in the Docker containers
-GROUP_ID=1000  # Group ID used in the Docker containers
\ No newline at end of file
+GROUP_ID=1000  # Group ID used in the Docker containers
+
+NODE_TAG=10
+COMPOSER_VERSION=2.6.5
+FPMHOST="fpm:9000"
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7a1444e..1dd7425 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,6 +4,7 @@ variables:
   DEPLOY_KUBERNETES_IMAGE: alpine/k8s:1.27.8
   KUBE_NAMESPACE: maps
   IMAGE_TAG_PREFIX: master
+  FPM_HOST: localhost:9000
 
 workflow:
   rules:
diff --git a/build/nginx/Dockerfile b/build/nginx/Dockerfile
index f61718e..dd24c4c 100644
--- a/build/nginx/Dockerfile
+++ b/build/nginx/Dockerfile
@@ -2,6 +2,7 @@ FROM nginx:1.25.3 as development
 
 ARG USER_ID=1000
 ARG GROUP_ID=1000
+ARG FPMHOST="fpm:9000"
 
 RUN deluser nginx
 RUN addgroup --gid $GROUP_ID mgmaps && useradd -d /home/mgmaps -u $USER_ID -g $GROUP_ID -m -s /bin/bash mgmaps
@@ -10,7 +11,8 @@ RUN cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime
 
 ADD ./build/nginx/config/nginx.conf /etc/nginx/nginx.conf
 RUN rm /etc/nginx/conf.d/default.conf
-ADD ./build/nginx/config/maps.conf /etc/nginx/conf.d/maps.conf
+ADD ./build/nginx/config/maps.conf /tmp/maps.conf
+RUN envsubst '$FPMHOST' < /tmp/maps.conf > /etc/nginx/conf.d/maps.conf
 
 # Fix directories the root image is using
 RUN mkdir -p /var/cache/nginx/client_temp && \
diff --git a/build/nginx/config/maps.conf b/build/nginx/config/maps.conf
index f5a0878..288a1b0 100644
--- a/build/nginx/config/maps.conf
+++ b/build/nginx/config/maps.conf
@@ -13,7 +13,7 @@ server {
     location ~ \.php$ {
         try_files $uri /index.php =404;
         fastcgi_split_path_info ^(.+\.php)(/.+)$;
-        fastcgi_pass fpm:9000;
+        fastcgi_pass $FPMHOST;
         fastcgi_index index.php;
         fastcgi_read_timeout 900;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
-- 
GitLab