Skip to content

Commit 6bef5cb

Browse files
committed
Keep empty outlet files instead of removing them
This is necessary because `replace` operation checks if file exists first. This is a fix for socketed template.
1 parent d5792cd commit 6bef5cb

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

templates/web.socketed.template.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ run:
2323
to: |
2424
listen unix:/shared/nginx.https.sock ssl;
2525
set_real_ip_from unix:;
26+
- replace:
27+
filename: "/etc/nginx/conf.d/outlets/before-server/10-redirect-http-to-https.conf"
28+
from: /listen 80;(\nlisten \[::\]:80;)?/
29+
to: |
30+
listen unix:/shared/nginx.http.sock;
31+
set_real_ip_from unix:;

templates/web.ssl.template.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ run:
99
listen 80;
1010
return 301 https://$$ENV_DISCOURSE_HOSTNAME$request_uri;
1111
}
12-
- exec: rm /etc/nginx/conf.d/outlets/server/10-http.conf
12+
- file:
13+
path: "/etc/nginx/conf.d/outlets/server/10-http.conf"
14+
contents: ""
1315
- file:
1416
hook: ssl
1517
path: "/etc/nginx/conf.d/outlets/server/20-https.conf"

templates/web.template.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,18 @@ run:
135135
- "cp $home/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf"
136136
- "rm /etc/nginx/sites-enabled/default"
137137
- "mkdir -p /var/nginx/cache"
138-
- "mkdir -p /etc/nginx/conf.d/outlets/before-server"
139-
- "mkdir -p /etc/nginx/conf.d/outlets/server"
140-
- "mkdir -p /etc/nginx/conf.d/outlets/discourse"
141138

142139
# Stop building the container if the Nginx outlets are missing
143140
- "grep -q 'outlets/before-server' /etc/nginx/conf.d/discourse.conf || ( >&2 echo 'The \"before-server\" Nginx outlet is missing. This version of discourse_docker is not compatible with the chosen Discourse version.' ; exit 1 )"
144141
- "grep -q 'outlets/server' /etc/nginx/conf.d/discourse.conf || ( >&2 echo 'The \"server\" Nginx outlet is missing. This version of discourse_docker is not compatible with the chosen Discourse version.' ; exit 1 )"
145142
- "grep -q 'outlets/discourse' /etc/nginx/conf.d/discourse.conf || ( >&2 echo 'The \"discourse\" Nginx outlet is missing. This version of discourse_docker is not compatible with the chosen Discourse version.' ; exit 1 )"
146143

144+
# Create placeholders for the Nginx outlets
145+
- "mkdir -p /etc/nginx/conf.d/outlets/before-server"
146+
- "mkdir -p /etc/nginx/conf.d/outlets/server"
147+
- "mkdir -p /etc/nginx/conf.d/outlets/discourse"
148+
- "touch /etc/nginx/conf.d/outlets/before-server/10-redirect-http-to-https.conf"
149+
147150
- replace:
148151
filename: /etc/nginx/nginx.conf
149152
from: pid /run/nginx.pid;

0 commit comments

Comments
 (0)