Skip to content

Commit af20fa8

Browse files
committed
1) Change the application to read parameters from environment variables if they are supplied. Otherwise read from config.js
2) Add dockerfiles that build container which can be used to run this as a web service. 3) Add dockeer-compolse.yml file which gets everything up and running! 4) To get this quickly working type: ``` TLS_DASHBOARD_HOSTS=google.com,baidu.com,bing.com docker-compose up ```
1 parent eeb5822 commit af20fa8

6 files changed

+47
-6
lines changed

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM alpine
2+
3+
RUN apk --update add nodejs
4+
RUN npm install -g http-server
5+
6+
COPY web_service /root/tls-dashboard/web_service
7+
WORKDIR /root/tls-dashboard
8+
9+
CMD http-server web_service

Dockerfile.cron

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM alpine
2+
3+
RUN apk --update add nodejs
4+
5+
COPY node_app /root/tls-dashboard/node_app
6+
WORKDIR /root/tls-dashboard
7+
8+
COPY tasks/renew-cert-info /etc/periodic/15min/renew-cert-info
9+
10+
CMD sh -c '/etc/periodic/15min/renew-cert-info && crond -f -d 8'

docker-compose.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: '2'
2+
services:
3+
"tls-dashboard":
4+
build: .
5+
image: tls-dashboard
6+
ports:
7+
- "8080:8080"
8+
volumes:
9+
- /root/tls-dashboard/web_service
10+
11+
"tls-dashboard-cron":
12+
build:
13+
context: .
14+
dockerfile: Dockerfile.cron
15+
image: tls-dashboard-cron
16+
volumes_from:
17+
- "tls-dashboard"
18+
environment:
19+
- TLS_DASHBOARD_HOSTS=${TLS_DASHBOARD_HOSTS}

node_app/config.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
var config = {
2-
connection_timeout : 5000,
2+
connection_timeout : process.env.TLS_DASHBOARD_CONNECTION_TIMEOUT || 5000,
33
output_file : {
4-
path: '../web_service/js/tls-dashboard/',
5-
name: 'certificates.js'
4+
path: process.env.TLS_DASHBOARD_OUTPUT_DIR || './web_service/js/tls-dashboard/',
5+
name: process.env.TLS_DASHBOARD_OUTPUT_FILENAME || 'certificates.js'
66
}
77
};
88

9-
module.exports = config;
9+
module.exports = config;

node_app/monitored_hosts.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var hosts = [
1+
var hosts = process.env.TLS_DASHBOARD_HOSTS ? process.env.TLS_DASHBOARD_HOSTS.split(',') : [
22
'www.google.com',
33
'www.twitter.com',
44
'sha256.badssl.com',
@@ -9,4 +9,4 @@ var hosts = [
99
'example.dev',
1010
'vsaq.dev'
1111
];
12-
module.exports = hosts;
12+
module.exports = hosts;

tasks/renew-cert-info

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
cd /root/tls-dashboard && node /root/tls-dashboard/node_app/get_cert_info.js

0 commit comments

Comments
 (0)