Skip to content

Commit c0272de

Browse files
committed
MOBILE-4304 ci: Configure SSL
1 parent ed75657 commit c0272de

File tree

3 files changed

+50
-9
lines changed

3 files changed

+50
-9
lines changed

.github/workflows/acceptance.yml

+27-7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ jobs:
4141
working-directory: app
4242
run: npm run build:test
4343

44+
- name: Generate SSL certificates
45+
working-directory: app
46+
run: |
47+
mkdir ./ssl
48+
openssl req -x509 -nodes \
49+
-days 365 \
50+
-newkey rsa:2048 \
51+
-keyout ./ssl/certificate.key \
52+
-out ./ssl/certificate.crt \
53+
-subj="/O=Moodle"
54+
4455
- name: Build Behat plugin
4556
working-directory: app
4657
run: ./scripts/build-behat-plugin.js ../plugin
@@ -111,11 +122,12 @@ jobs:
111122

112123
- uses: actions/cache/save@v4
113124
with:
114-
key: build-${{ github.sha }}
115-
path: |
116-
app/node_modules/**/*
117-
app/www/**/*
118-
plugin/**/*
125+
key: build-${{ github.sha }}
126+
path: |
127+
app/ssl/**/*
128+
app/node_modules/**/*
129+
app/www/**/*
130+
plugin/**/*
119131
120132
behat:
121133
runs-on: ubuntu-latest
@@ -157,14 +169,22 @@ jobs:
157169
with:
158170
key: build-${{ github.sha }}
159171
path: |
172+
app/ssl/**/*
160173
app/node_modules/**/*
161174
app/www/**/*
162175
plugin/**/*
163176
164177
- name: Launch Docker images
165178
working-directory: app
166179
run: |
167-
docker run -d --rm -p 8001:80 --name moodleapp -v ./www:/usr/share/nginx/html -v ./nginx.conf:/etc/nginx/conf.d/default.conf nginx:alpine
180+
docker run -d --rm \
181+
-p 8001:443 \
182+
--name moodleapp \
183+
-v ./www:/usr/share/nginx/html \
184+
-v ./nginx.conf:/etc/nginx/conf.d/default.conf \
185+
-v ./ssl/certificate.crt:/etc/ssl/certificate.crt \
186+
-v ./ssl/certificate.key:/etc/ssl/certificate.key \
187+
nginx:alpine
168188
docker run -d --rm -p 8002:80 --name bigbluebutton moodlehq/bigbluebutton_mock:latest
169189
170190
- name: Initialise moodle-plugin-ci
@@ -184,7 +204,7 @@ jobs:
184204
DB: pgsql
185205
MOODLE_BRANCH: ${{ github.event.inputs.moodle_branch || 'main' }}
186206
MOODLE_REPO: ${{ github.event.inputs.moodle_repository || 'https://github.com/moodle/moodle.git' }}
187-
MOODLE_BEHAT_IONIC_WWWROOT: http://localhost:8001
207+
MOODLE_BEHAT_IONIC_WWWROOT: https://localhost:8001
188208
MOODLE_BEHAT_DEFAULT_BROWSER: chrome
189209

190210
- name: Update config

Dockerfile

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,17 @@ ARG build_command="npm run build:prod"
2323
COPY . /app
2424
RUN ${build_command}
2525

26+
# Generate SSL certificate
27+
RUN mkdir /app/ssl
28+
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /app/ssl/certificate.key -out /app/ssl/certificate.crt -subj="/O=Moodle"
29+
2630
## SERVE STAGE
2731
FROM nginx:alpine as serve-stage
2832

2933
# Copy assets & config
3034
COPY --from=build-stage /app/www /usr/share/nginx/html
35+
COPY --from=build-stage /app/ssl/certificate.crt /etc/ssl/certificate.crt
36+
COPY --from=build-stage /app/ssl/certificate.key /etc/ssl/certificate.key
3137
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
32-
HEALTHCHECK --interval=10s --timeout=4s CMD curl -f http://localhost/assets/env.json || exit 1
38+
EXPOSE 443
39+
HEALTHCHECK --interval=10s --timeout=4s CMD curl --insecure -f https://localhost/assets/env.json || exit 1

nginx.conf

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
server {
2-
listen 0.0.0.0:80;
2+
listen 80;
3+
listen 443 ssl;
34
root /usr/share/nginx/html;
45
server_tokens off;
56
access_log off;
67

8+
# Configure SSL
9+
if ($scheme = "http") {
10+
return 301 https://$host$request_uri;
11+
}
12+
13+
ssl_certificate /etc/ssl/certificate.crt;
14+
ssl_certificate_key /etc/ssl/certificate.key;
15+
ssl_protocols TLSv1.3;
16+
17+
# Enable OPFS
18+
add_header Cross-Origin-Opener-Policy "same-origin";
19+
add_header Cross-Origin-Embedder-Policy "require-corp";
20+
721
location / {
822
try_files $uri $uri/ /index.html;
923
}

0 commit comments

Comments
 (0)