Skip to content

Commit

Permalink
Merge pull request #171 from json-scada/master
Browse files Browse the repository at this point in the history
Add Dozzle to monitor logs on Docker Demo.
  • Loading branch information
riclolsen authored Nov 15, 2024
2 parents cb9f327 + 19737b4 commit 83415c1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
23 changes: 20 additions & 3 deletions demo-docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,23 +274,22 @@ services:
- JS_IP_BIND=0.0.0.0
- JS_HTTP_PORT=8080
- JS_GRAFANA_SERVER=http://grafana:3000
- JS_LOGIO_SERVER=http://dozzle:6688
- PGPORT=5432
- PGHOST=jsdemo_timescaledb
- PGDATABASE=json_scada
- PGUSER=json_scada
- PGPASSWORD=
volumes:
- ../src/server_realtime_auth:/server_realtime_auth
#- ../src/htdocs:/htdocs
#- ../src/htdocs-admin:/htdocs-admin
#- ../src/htdocs-login:/htdocs-login
- ../src/AdminUI:/AdminUI
- ../svg:/svg
- ./conf:/conf
- ./log:/log
links:
- jsdemo_mongorsn1
- grafana
- dozzle
# exports the HTTP port to the main host
ports:
- 8080:8080
Expand Down Expand Up @@ -400,6 +399,24 @@ services:
networks:
- jsdemo_net

# monitoring of logs of the docker containers
dozzle:
container_name: dozzle
image: amir20/dozzle:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DOZZLE_ADDR=0.0.0.0:6688
- DOZZLE_BASE=/log-io
- DOZZLE_NO_ANALYTICS=true
# - DOZZLE_LEVEL=debug
ports:
- 6688:6688
expose:
- "6688"
networks:
- jsdemo_net

networks:
jsdemo_net:
driver: bridge
21 changes: 14 additions & 7 deletions src/server_realtime_auth/app/routes/user.routes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const path = require('path')
const express = require('express')
const httpProxy = require('express-http-proxy')
const { legacyCreateProxyMiddleware: createProxyMiddleware } = require('http-proxy-middleware');
const {
legacyCreateProxyMiddleware: createProxyMiddleware,
} = require('http-proxy-middleware')
const { authJwt } = require('../middlewares')
const controller = require('../controllers/user.controller')
const authController = require('../controllers/auth.controller')
Expand Down Expand Up @@ -61,15 +62,21 @@ module.exports = function (
httpProxy(metabaseServer)
)

// reverse proxy for log.io
// reverse proxy for log.io on Windows
// for docker it will be used Dozzle
app.use(
'/log-io',
[authJwt.verifyToken],
function (req, _, next) {
authController.addXWebAuthUser(req)
next()
},
httpProxy(logioServer)
logioServer.indexOf('//dozzle') === -1
? httpProxy(logioServer)
: createProxyMiddleware({
target: logioServer,
changeOrigin: true,
})
)
const wsProxy = createProxyMiddleware({
target: logioServer,
Expand All @@ -86,7 +93,7 @@ module.exports = function (
wsProxy
)
app.on('upgrade', wsProxy.upgrade)
app.use('/static', express.static('../log-io/ui/build/static'));
app.use('/static', express.static('../log-io/ui/build/static'))

app.post(accessPoint, opcApi) // realtime data API

Expand All @@ -101,15 +108,15 @@ module.exports = function (
)

app.get(accessPoint + 'test/admin', [authJwt.isAdmin], controller.adminBoard)

app.use('/svg', [authJwt.verifyToken], express.static('../../svg'))

// production
app.use('/', express.static('../AdminUI/dist'))
app.use('/login', express.static('../AdminUI/dist'))
app.use('/dashboard', express.static('../AdminUI/dist'))
app.use('/admin', express.static('../AdminUI/dist'))

// development
//app.use('/', httpProxy('localhost:3000/'))
//app.use('/login', httpProxy('localhost:3000/'))
Expand Down

0 comments on commit 83415c1

Please sign in to comment.