@@ -85,6 +85,14 @@ describe("self-host docker compose", () => {
8585 expect ( dockerfile ) . not . toContain ( "--environment" ) ;
8686 } ) ;
8787
88+ it ( "keeps PostHog out of the self-host web image" , ( ) => {
89+ const dockerfile = readRepoFile ( "self-host/Dockerfile.web" ) ;
90+
91+ expect ( dockerfile ) . not . toContain ( "COMPASS_WEB_BUILD_CONFIG_B64" ) ;
92+ expect ( dockerfile ) . not . toContain ( "POSTHOG_" ) ;
93+ expect ( dockerfile ) . not . toContain ( "posthog:" ) ;
94+ } ) ;
95+
8896 it ( "mounts compass.yaml into the backend container" , ( ) => {
8997 const compose = readFileSync ( join ( import . meta. dir , "compose.yaml" ) , {
9098 encoding : "utf8" ,
@@ -168,6 +176,51 @@ describe("staging deploy workflow", () => {
168176 ) ;
169177 } ) ;
170178
179+ it ( "builds cloud deploy web images from a GitHub-only Dockerfile with PostHog config" , ( ) => {
180+ const workflow = readRepoFile ( ".github/workflows/_deploy-environment.yml" ) ;
181+ const dockerfile = readRepoFile ( ".github/docker/Dockerfile.web" ) ;
182+
183+ expect ( workflow ) . toContain ( "file: .github/docker/Dockerfile.web" ) ;
184+ expect ( workflow ) . toContain ( "POSTHOG_KEY=$" ) ;
185+ expect ( workflow ) . toContain ( "POSTHOG_HOST=$" ) ;
186+ expect ( workflow ) . not . toContain ( "COMPASS_WEB_BUILD_CONFIG_B64" ) ;
187+ expect ( workflow ) . not . toContain ( "base64" ) ;
188+ expect ( dockerfile ) . toContain ( "ARG POSTHOG_KEY=" ) ;
189+ expect ( dockerfile ) . toContain ( "ARG POSTHOG_HOST=" ) ;
190+ expect ( dockerfile ) . toContain ( "'posthog:'" ) ;
191+ } ) ;
192+
193+ it ( "writes Kit email config only for production deploys" , ( ) => {
194+ const workflow = readRepoFile ( ".github/workflows/_deploy-environment.yml" ) ;
195+
196+ expect ( workflow ) . toContain (
197+ "KIT_USER_TAG_ID: $" . concat (
198+ "{{ inputs.environment == 'production' && vars.KIT_USER_TAG_ID || '' }}" ,
199+ ) ,
200+ ) ;
201+ expect ( workflow ) . toContain (
202+ "KIT_API_SECRET: $" . concat (
203+ "{{ inputs.environment == 'production' && secrets.KIT_API_SECRET || '' }}" ,
204+ ) ,
205+ ) ;
206+ expect ( workflow ) . toContain (
207+ 'if [ "$' . concat ( '{{ inputs.environment }}" = "production" ]; then' ) ,
208+ ) ;
209+ expect ( workflow ) . toContain (
210+ "Production deploy requires KIT_API_SECRET and KIT_USER_TAG_ID" ,
211+ ) ;
212+ expect ( workflow ) . toContain (
213+ 'if [ -n "$KIT_API_SECRET" ] && [ -n "$KIT_USER_TAG_ID" ]; then' ,
214+ ) ;
215+ expect ( workflow ) . toContain ( "'email:'" ) ;
216+ expect ( workflow ) . toContain (
217+ 'kitApiSecret: \\"$' . concat ( '{KIT_API_SECRET}\\"' ) ,
218+ ) ;
219+ expect ( workflow ) . toContain (
220+ 'kitUserTagId: \\"$' . concat ( '{KIT_USER_TAG_ID}\\"' ) ,
221+ ) ;
222+ } ) ;
223+
171224 it ( "runs deploy health checks after each staging deploy" , ( ) => {
172225 const workflow = readRepoFile ( ".github/workflows/deploy-staging.yml" ) ;
173226
0 commit comments