Skip to content

Commit 67f0a69

Browse files
committed
DM-11547: dockerize apache https proxy.
- use letsencrypt for public site, and self-signed for development - add support for authentication via mod_auth_openidc - expand build script to exposes configurable global variables to javascript
1 parent 91f9bcf commit 67f0a69

File tree

22 files changed

+544
-32
lines changed

22 files changed

+544
-32
lines changed

buildScript/depends.gincl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,16 @@ task dockerImage (dependsOn: loadConfig) {
184184
ext.docker_repo = "ipac/firefly"
185185
ext.docker_registry = ''
186186
ext.docker_tag = 'latest'
187+
ext.copy_res = true
187188

188189
doLast {
189190
// copy artifacts to staging directory
190-
copy {
191-
from ("${project.distDir}") { include '*.war' }
192-
from ("${fireflyPath}/docker/base") { include '*' }
193-
into "${buildDir}/docker"
191+
if (copy_res) {
192+
copy {
193+
from ("${project.distDir}") { include '*.war' }
194+
from ("${fireflyPath}/docker/base") { include '*' }
195+
into "${buildDir}/docker"
196+
}
194197
}
195198

196199
try {
@@ -286,6 +289,13 @@ ext.NODE = { ...cmd ->
286289
environment 'WP_BUILD_DIR': wpBuildDir
287290
environment 'NODE_ENV': (project.env == 'local' ? 'development' : 'production')
288291
commandLine cmd
292+
for (String key : project.appConfigProps.keySet()) {
293+
if (key.startsWith('__$')) {
294+
environment (key, project.appConfigProps[key])
295+
println ">> " + key + " = " + project.appConfigProps[key]
296+
}
297+
}
298+
289299
}
290300
return res;
291301
}

buildScript/gwt.gincl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ task gwtCompile (type: JavaExec, dependsOn: [gwt, loadConfig]) {
2525
group = "Build"
2626

2727
outputs.upToDateWhen { false }
28-
inputs.source sourceSets.main.java.srcDirs
28+
inputs.file sourceSets.main.java.srcDirs
2929
inputs.dir sourceSets.main.output.resourcesDir
3030
outputs.dir gwt.buildDir
3131

@@ -90,7 +90,7 @@ task gwtRun (type: JavaExec, dependsOn: [gwt, loadConfig]) {
9090
description= 'GWT DevMode'
9191
group = MISC_GROUP
9292

93-
inputs.source sourceSets.main.java.srcDirs
93+
inputs.file sourceSets.main.java.srcDirs
9494
inputs.dir sourceSets.main.output.resourcesDir
9595

9696
main = 'com.google.gwt.dev.DevMode'
@@ -134,7 +134,7 @@ task gwtSuperDev (type: JavaExec, dependsOn: [gwt, loadConfig]) {
134134
description= 'GWT SuperDev Mode'
135135
group = MISC_GROUP
136136

137-
inputs.source sourceSets.main.java.srcDirs
137+
inputs.file sourceSets.main.java.srcDirs
138138
inputs.dir sourceSets.main.output.resourcesDir
139139

140140
main = 'com.google.gwt.dev.codeserver.CodeServer'

buildScript/gwt_webapp.gincl

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ configurations {
3030
}
3131
}
3232

33-
task jsTest (dependsOn: [loadConfig]) << {
34-
if (file("package.json").exists()) {
35-
println ">> running JavaScript test..."
36-
def res = project.ext.NODE 'yarn', 'run', 'test-unit'
37-
if (res.getExitValue() != 0) {
38-
throw new GradleException("JavaScript test fail.")
33+
task jsTest (dependsOn: [loadConfig]) {
34+
doLast {
35+
if (file("package.json").exists()) {
36+
println ">> running JavaScript test..."
37+
def res = project.ext.NODE 'yarn', 'run', 'test-unit'
38+
if (res.getExitValue() != 0) {
39+
throw new GradleException("JavaScript test fail.")
40+
}
3941
}
4042
}
4143
}
@@ -177,23 +179,25 @@ clean {
177179
delete "${war.destinationDir}/${webapp.baseWarName}.war"
178180
}
179181

180-
task deploy (dependsOn: [loadConfig, webapp]) << {
182+
task deploy (dependsOn: [loadConfig, webapp]) {
181183
description= 'Deploy webapp(war file) to Tomcat. Require ${tomcat_home} property'
182184
group = MAIN_GROUP
183185

184-
if (!project.hasProperty("tomcat_home")) {
185-
throw ProjectConfigurationException("tomcat_home property is not found.")
186-
}
187-
if (!file("$war.destinationDir/${webapp.baseWarName}.war").exists()) {
188-
println ">> ${webapp.baseWarName}.war not found. Skipping deploy."
189-
throw new StopExecutionException("${webapp.baseWarName}.war not found. Skipping deploy.")
190-
}
186+
doLast {
187+
if (!project.hasProperty("tomcat_home")) {
188+
throw ProjectConfigurationException("tomcat_home property is not found.")
189+
}
190+
if (!file("$war.destinationDir/${webapp.baseWarName}.war").exists()) {
191+
println ">> ${webapp.baseWarName}.war not found. Skipping deploy."
192+
throw new StopExecutionException("${webapp.baseWarName}.war not found. Skipping deploy.")
193+
}
191194

192-
copy {
193-
println ">> deploying file:$war.destinationDir/${webapp.baseWarName}.war"
194-
delete("$tomcat_home/webapps/${webapp.baseWarName}")
195-
from("$war.destinationDir/${webapp.baseWarName}.war")
196-
into "$tomcat_home/webapps/"
195+
copy {
196+
println ">> deploying file:$war.destinationDir/${webapp.baseWarName}.war"
197+
delete("$tomcat_home/webapps/${webapp.baseWarName}")
198+
from("$war.destinationDir/${webapp.baseWarName}.war")
199+
into "$tomcat_home/webapps/"
200+
}
197201
}
198202
}
199203

config/common.prop

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ [email protected]@
4242
4343

4444
45+
4546

4647

4748

docker/proxy-dev/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM birgerk/apache-letsencrypt
2+
3+
RUN apt-get update && \
4+
apt-get -f --assume-yes install libapache2-mod-auth-openidc && \
5+
rm -rf /var/lib/apt/lists/*
6+
7+
COPY ./others/*.conf /etc/apache2/conf-enabled/
8+
9+
RUN a2enmod proxy; \
10+
a2enmod proxy_http; \
11+
a2enmod proxy_wstunnel; \
12+
a2enmod auth_openidc
13+
14+
RUN mkdir /etc/apache2/certs; \
15+
openssl req \
16+
-new \
17+
-newkey rsa:4096 \
18+
-days 365 \
19+
-nodes \
20+
-x509 \
21+
-subj "/C=US/ST=CA/L=dev/O=dev/CN=localhost" \
22+
-keyout /etc/apache2/certs/localhost.key \
23+
-out /etc/apache2/certs/localhost.cert
24+
25+
26+
EXPOSE 80 443

docker/proxy-dev/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
dockerImage {
3+
4+
docker_repo = "ipac/proxy-dev"
5+
docker_registry = ''
6+
docker_tag = 'latest'
7+
copy_res = false
8+
9+
doFirst {
10+
// copy artifacts to staging directory
11+
copy {
12+
from (projectDir) include '**/*'
13+
into "${buildDir}/docker"
14+
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: project.appConfigProps)
15+
}
16+
}
17+
}

docker/proxy-dev/others/openid.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
OIDCProviderMetadataURL https://test.cilogon.org/.well-known/openid-configuration
2+
OIDCClientID @oidc_client_id@
3+
OIDCClientSecret @oidc_client_secret@
4+
5+
OIDCRedirectURI @oidc_redirect_uri@
6+
OIDCCryptoPassphrase pass357code
7+
8+
OIDCScope "openid profile email org.cilogon.userinfo edu.uiuc.ncsa.myproxy.getcert"
9+
OIDCAuthNHeader X-Forwarded-User
10+
11+
<Location /suit/>
12+
AuthType openid-connect
13+
Require claim "isMemberOf~.cn=lsst_users|cn=lsst_pdac"
14+
</Location>

docker/proxy-dev/others/proxy.conf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Load these modules if not already loaded
2+
<IfModule !proxy_module>
3+
LoadModule proxy_module modules/mod_proxy.so
4+
</IfModule>
5+
<IfModule !proxy_http_module>
6+
LoadModule proxy_http_module modules/mod_proxy_http.so
7+
</IfModule>
8+
<IfModule !proxy_wstunnel_module>
9+
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
10+
</IfModule>
11+
<IfModule !rewrite_module>
12+
LoadModule rewrite_module modules/mod_rewrite.so
13+
</IfModule>
14+
15+
16+
ProxyRequests Off
17+
ProxyPreserveHost On
18+
ProxyStatus On
19+
20+
21+
## Hydra app for firefly
22+
ProxyPass /firefly/sticky/firefly/events ws://${docker_host}:8080/firefly/sticky/firefly/events
23+
ProxyPass /firefly http://${docker_host}:8080/firefly
24+
ProxyPassReverse /firefly http://${docker_host}:8080/firefly
25+
26+
## Hydra app for suit
27+
ProxyPass /suit/sticky/firefly/events ws://${docker_host}:8080/suit/sticky/firefly/events
28+
ProxyPass /suit http://${docker_host}:8080/suit
29+
ProxyPassReverse /suit http://${docker_host}:8080/suit
30+
31+
32+
## end proxy config for Hydra support
33+
34+
35+

docker/proxy-dev/others/site.conf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<VirtualHost *:80>
2+
ServerName localhost
3+
4+
</VirtualHost>
5+
6+
<VirtualHost *:443>
7+
ServerName localhost
8+
9+
SSLEngine on
10+
11+
SSLCertificateFile /etc/apache2/certs/localhost.cert
12+
SSLCertificateKeyFile /etc/apache2/certs/localhost.key
13+
14+
RequestHeader set X-Forwarded-Proto "https"
15+
RequestHeader set X-Forwarded-Port "443"
16+
<FilesMatch "\.(cgi|shtml|phtml|php)$">
17+
SSLOptions +StdEnvVars
18+
</FilesMatch>
19+
20+
</VirtualHost>

docker/proxy-dev/proxyctl.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
case "$1" in
3+
start)
4+
docker start proxy-dev
5+
;;
6+
stop)
7+
docker stop proxy-dev
8+
;;
9+
shell)
10+
docker exec -it proxy-dev /bin/bash
11+
;;
12+
clean)
13+
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
14+
;;
15+
update)
16+
cd /hydra/cm/firefly
17+
gradle proxyDev:dockerImage
18+
docker stop proxy-dev
19+
docker container rm proxy-dev
20+
21+
docker run -d \
22+
-p 80:80 \
23+
-p 443:443 \
24+
-e "docker_host=`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | tail -1`" \
25+
--name proxy-dev ipac/proxy-dev
26+
27+
# -e "DOMAINS=`hostname`" \
28+
29+
# -e "STAGING=proxy" \
30+
31+
;;
32+
*)
33+
echo $"Usage: proxyctl.sh [start|stop|shell|clean|update]"
34+
exit
35+
esac
36+

docker/proxy/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM birgerk/apache-letsencrypt
2+
3+
4+
#RUN apt-get update && \
5+
# apt-get -f stretch install libapache2-mod-auth-openidc && \
6+
# rm -rf /var/lib/apt/lists/*
7+
8+
#RUN ln -s /usr/lib/apache2/modules/mod_auth_openidc.so modules/mod_auth_openidc.so
9+
COPY ./others/*.conf /etc/apache2/conf-enabled/
10+
11+
RUN a2enmod proxy; \
12+
a2enmod proxy_http; \
13+
a2enmod proxy_wstunnel
14+
15+
EXPOSE 80 443
16+
17+
ENTRYPOINT ["httpd-foreground"]

docker/proxy/build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
dockerImage {
3+
4+
docker_repo = "ipac/proxy"
5+
docker_registry = ''
6+
docker_tag = 'latest'
7+
copy_res = false
8+
9+
doFirst {
10+
// copy artifacts to staging directory
11+
copy {
12+
from (projectDir) include '**/*'
13+
into "${buildDir}/docker"
14+
}
15+
}
16+
}

docker/proxy/others/proxy.conf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Load these modules if not already loaded
2+
<IfModule !proxy_module>
3+
LoadModule proxy_module modules/mod_proxy.so
4+
</IfModule>
5+
<IfModule !proxy_http_module>
6+
LoadModule proxy_http_module modules/mod_proxy_http.so
7+
</IfModule>
8+
<IfModule !proxy_wstunnel_module>
9+
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
10+
</IfModule>
11+
<IfModule !rewrite_module>
12+
LoadModule rewrite_module modules/mod_rewrite.so
13+
</IfModule>
14+
15+
16+
ProxyRequests Off
17+
ProxyPreserveHost On
18+
ProxyStatus On
19+
20+
21+
## Hydra app for firefly
22+
ProxyPass /firefly/sticky/firefly/events ws://firefly:8080/firefly/sticky/firefly/events
23+
ProxyPass /firefly http://firefly:8080/firefly
24+
ProxyPassReverse /firefly http://firefly:8080/firefly
25+
26+
## Hydra app for suit
27+
ProxyPass /suit/sticky/firefly/events ws://firefly:8080/suit/sticky/firefly/events
28+
ProxyPass /suit http://firefly:8080/suit
29+
ProxyPassReverse /suit http://firefly:8080/suit
30+
31+
32+
## end proxy config for Hydra support
33+
34+
35+

docker/proxy/proxyctl.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
case "$1" in
3+
start)
4+
docker start proxy
5+
;;
6+
stop)
7+
docker stop proxy
8+
;;
9+
shell)
10+
docker exec -it proxy /bin/bash
11+
;;
12+
update)
13+
docker stop proxy
14+
docker container rm proxy
15+
16+
docker pull ipac/proxy
17+
docker run -d \
18+
-p 80:80 \
19+
-p 443:443 \
20+
-e "DOMAINS=`hostname`" \
21+
22+
--network=local_nw \
23+
--restart=unless-stopped \
24+
--name proxy ipac/proxy
25+
26+
# -e "DOMAINS=`hostname`" \
27+
# -e "STAGING=proxy" \
28+
;;
29+
*)
30+
echo $"Usage: proxyctl.sh [start|stop|shell|update]"
31+
exit
32+
esac
33+

0 commit comments

Comments
 (0)