From 266eca5f4bddbcaf9cb7ea3ee00d4b7a928589b9 Mon Sep 17 00:00:00 2001
From: Daniel Bimschas <daniel.bimschas@inoio.de>
Date: Wed, 16 Aug 2023 23:12:05 +0200
Subject: [PATCH] HOLI-5413: make local environment work for push gateway

---
 .envrc                                                |  1 +
 .envrc-push-gateway.local.template                    | 10 ++++++++++
 .envrc.local.template                                 | 11 -----------
 .gitignore                                            |  6 ++++--
 .../sygnal.yaml.template                              |  0
 docker-compose.yaml                                   |  4 +++-
 generate-push-gateway-config.sh                       |  2 +-
 7 files changed, 19 insertions(+), 15 deletions(-)
 create mode 100644 .envrc-push-gateway.local.template
 rename sygnal.yaml.template => data-push-gateway/sygnal.yaml.template (100%)

diff --git a/.envrc b/.envrc
index 792a46b..e2d92ca 100644
--- a/.envrc
+++ b/.envrc
@@ -7,6 +7,7 @@ fi
 
 # loads personal (secret) data from separate env file (not checked in)
 source_env_if_exists .envrc.local
+source_env_if_exists .envrc-push-gateway.local
 
 type yarn >/dev/null 2>&1 && PATH="$PATH:$(yarn global bin)"
 export PATH
\ No newline at end of file
diff --git a/.envrc-push-gateway.local.template b/.envrc-push-gateway.local.template
new file mode 100644
index 0000000..bf8a697
--- /dev/null
+++ b/.envrc-push-gateway.local.template
@@ -0,0 +1,10 @@
+# ========= SYGNAL PUSH GATEWAY CONFIGURATION =========
+export SYGNAL_CONF=/data/sygnal.yaml
+
+# API key for Firebase Cloud Messaging
+export HOLI_CHAT_PUSH_GATEWAY_FCM_API_KEY=
+
+export APNS_KEYFILE=/data/apns_keyfile_staging.p8
+export APNS_KEY_ID=
+export APNS_TEAM_ID=
+export APNS_TOPIC=
\ No newline at end of file
diff --git a/.envrc.local.template b/.envrc.local.template
index ff64895..1bc28ee 100644
--- a/.envrc.local.template
+++ b/.envrc.local.template
@@ -23,14 +23,3 @@ export HOLI_CHAT_FORM_SECRET=
 
 # shared secret used to generate access tokens within Synapse to be used for subsequent client requests
 export HOLI_CHAT_MACAROON_SECRET_KEY= 
-
-
-# ========= SYGNAL PUSH GATEWAY CONFIGURATION =========
-
-# API key for Firebase Cloud Messaging
-export HOLI_CHAT_PUSH_GATEWAY_FCM_API_KEY=
-
-export APNS_KEYFILE=
-export APNS_KEY_ID=
-export APNS_TEAM_ID=
-export APNS_TOPIC=
diff --git a/.gitignore b/.gitignore
index cdf5ff2..3484870 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,9 @@
 .envrc.local
+.envrc-push-gateway.local
 sygnal.yaml
 homeserver.yaml
 media_store
 *.key
-apns-test/apns_keyfile_staging.p8
-apns-test/node_modules/
\ No newline at end of file
+apns-test/node_modules/
+data-push-gateway/apns_keyfile_staging.p8
+apns-test/apns_keyfile_staging.p8
\ No newline at end of file
diff --git a/sygnal.yaml.template b/data-push-gateway/sygnal.yaml.template
similarity index 100%
rename from sygnal.yaml.template
rename to data-push-gateway/sygnal.yaml.template
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 4c05512..f1706eb 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -25,8 +25,10 @@ services:
     image: matrixdotorg/sygnal
     container_name: chat-push-gateway
     restart: always
+    env_file:
+      - ./.envrc-push-gateway.local
     volumes:
-      - ./sygnal.yaml:/sygnal.yaml
+      - ./data-push-gateway:/data
     ports:
       - 8050:5000
     networks:
diff --git a/generate-push-gateway-config.sh b/generate-push-gateway-config.sh
index a10f05a..0f36943 100755
--- a/generate-push-gateway-config.sh
+++ b/generate-push-gateway-config.sh
@@ -1,2 +1,2 @@
 #!/bin/sh
-envsubst < ./sygnal.yaml.template > ./sygnal.yaml
+envsubst < ./data-push-gateway/sygnal.yaml.template > ./data-push-gateway/sygnal.yaml
-- 
GitLab