Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-du-car committed Jan 12, 2024
1 parent 535c4c6 commit ebd7abd
Show file tree
Hide file tree
Showing 16 changed files with 231 additions and 128 deletions.
25 changes: 1 addition & 24 deletions telematic_system/docker-compose.dbs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,4 @@ services:
- DOCKER_INFLUXDB_INIT_RETENTION=${INFLUXDB_DEV_RETENTION}
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${DOCKER_INFLUXDB_INIT_ADMIN_TOKEN}
volumes:
- /opt/influxdb2/data:/var/lib/influxdb2 # data directory
mysqldb:
image: mysql:5.7
container_name: mysql
restart: always
environment:
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_password
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password
ports:
- '3306:3306'
secrets:
- mysql_password
- mysql_root_password
volumes:
- mysql-datavolume:/var/lib/mysql
secrets:
mysql_password:
file: ./secrets/mysql_password.txt
mysql_root_password:
file: ./secrets/mysql_root_password.txt
volumes:
mysql-datavolume:
- /opt/influxdb2/data:/var/lib/influxdb2 # data directory
149 changes: 149 additions & 0 deletions telematic_system/docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
version: "3"
services:
influxdb:
image: influxdb:${INFLUXDB_DEV_TAG}
container_name: influxdb-dev
ports:
- '8086:8086'
# restart: always
logging:
options:
max-size: "10m"
max-file: "1"
environment:
- DOCKER_INFLUXDB_INIT_CLI_CONFIG_NAME=${DOCKER_INFLUXDB_INIT_CLI_CONFIG_NAME}
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=${INFLUXDB_DEV_INIT_USERNAME}
- DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUXDB_DEV_INIT_PASSWORD}
- DOCKER_INFLUXDB_INIT_BUCKET=${INFLUXDB_DEV_INIT_BUCKET}
- DOCKER_INFLUXDB_INIT_ORG=${INFLUXDB_DEV_ORG}
- DOCKER_INFLUXDB_INIT_RETENTION=${INFLUXDB_DEV_RETENTION}
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${DOCKER_INFLUXDB_INIT_ADMIN_TOKEN}
volumes:
- /opt/influxdb2/data:/var/lib/influxdb2 # data directory
mysqldb:
image: mysql:5.7
restart: always
environment:
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_password
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password
ports:
- '3307:3306'
secrets:
- mysql_password
- mysql_root_password
volumes:
- mysql-datavolume:/var/lib/mysql
nats:
image: 'nats:2.7.3-alpine3.15'
restart: always
logging:
options:
max-size: "2g"
max-file: "1"
network_mode: host
grafana:
build:
context: "./telematic_apps/grafana"
restart: always
logging:
options:
max-size: "10m"
max-file: "1"
network_mode: host
volumes:
- /opt/grafana/logs:/var/log/grafana
- ./telematic_apps/grafana/grafana.ini:/etc/grafana/grafana.ini
- /opt/grafana/data:/var/lib/grafana
- /opt/grafana/provisioning:/home/grafana/conf/provisioning
- /home/ubuntu/.aws/credentials:/usr/share/grafana/.aws/credentials
user: "472" #grafana user id
telematic_web_server:
build:
context: "./telematic_apps/web_app/server"
restart: always
logging:
options:
max-size: "10m"
max-file: "1"
network_mode: host
environment:
- NODE_ENV=dev.comelopment
- CHOKIDAR_USEPOLLING=true
- ALLOW_CLIENT_URL=http://local.cav-telematics.com:8888
- GRAFANA_HTPASSWORD=/opt/apache2/grafana_htpasswd
- SESSION_TIMEOUT=3600
- SECRET=my_secret_telematic_ui
# Server port
- PORT=9010
# MYSQL DB credentials. Need to be replaced with actual MYSQL DB during deployment
- DB_HOST=127.0.0.1
- DB_PORT=3307
- DB_USER=telematic
- DB_PASSWORD=telematic
- GRAFANA_DB=wfd_grafana
volumes:
- /opt/apache2/grafana_htpasswd:/opt/apache2/grafana_htpasswd

telematic_web_client:
build:
context: "./telematic_apps/web_app/client"
args:
REACT_APP_MESSAGING_SERVER_URI: "http://topic-service.local.cav-telematics.com:8888"
REACT_APP_WEB_SERVER_URI: "http://ui-service.local.cav-telematics.com:8888"
REACT_APP_GRAFANA_URI: "http://grafana.local.cav-telematics.com:8888/grafana"
restart: always
logging:
options:
max-size: "10m"
max-file: "1"
network_mode: host
depends_on:
- telematic_web_server

apache2:
build:
context: "./telematic_apps/apache2"
dockerfile: "./local.Dockerfile"
restart: always
logging:
options:
max-size: "10m"
max-file: "1"
network_mode: host
environment:
- CLIENT_LOCAL_URL=http://127.0.0.1:8082/
- GRAFANA_LOCAL_URL=http://127.0.0.1:3000/
- TOPICSERVICE_LOCAL_URL=http://127.0.0.1:8080/
- UISERVICE_LOCAL_URL=http://127.0.0.1:9010/
depends_on:
- grafana
- telematic_web_client
- telematic_web_server
volumes:
- /opt/apache2/grafana_htpasswd:/etc/apache2/grafana_htpasswd

telematic_messaging_server:
build:
context: "./telematic_cloud_messaging"
dockerfile: "local.Dockerfile"
depends_on:
- nats
restart: always
logging:
options:
max-size: "2g"
max-file: "1"
network_mode: host
environment:
- NATS_URI=nats://localhost:4222

secrets:
mysql_password:
file: ./secrets/mysql_password.txt
mysql_root_password:
file: ./secrets/mysql_root_password.txt
volumes:
mysql-datavolume:
83 changes: 0 additions & 83 deletions telematic_system/docker-compose.webapp-local.yml

This file was deleted.

2 changes: 2 additions & 0 deletions telematic_system/local.data.mysql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

docker exec -i mysql mysql -utelematic -ptelematic wfd_grafana < ./scripts/database/mysql_insert_values.sql
25 changes: 25 additions & 0 deletions telematic_system/local.setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
echo '127.0.0.1 grafana.local.cav-telematics.com' >> /etc/hosts
echo '127.0.0.1 ui-service.local.cav-telematics.com' >> /etc/hosts
echo '127.0.0.1 topic-service.local.cav-telematics.com' >> /etc/hosts
echo '127.0.0.1 local.cav-telematics.com' >> /etc/hosts
if [ -d /opt/grafana ]; then
echo "Directory /opt/grafana exists."
else
mkdir /opt/grafana
fi
chmod 777 -R /opt/grafana

if [ /opt/apache2/grafana_htpasswd ]; then
echo "File /opt/apache2/grafana_htpasswd exists."
else
touch /opt/apache2/grafana_htpasswd
fi

if [ -d /opt/influxdb2 ]; then
echo "Directory /opt/influxdb2 exists."
else
mkdir /opt/influxdb2
fi
chmod 777 -R /opt/influxdb2

cp telematic-local.env .env
7 changes: 0 additions & 7 deletions telematic_system/setup.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<VirtualHost *:80>
<VirtualHost *:8888>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
Expand All @@ -9,7 +9,7 @@
#ServerName www.example.com

ServerAdmin admin@authproxy
ServerName grafana.local.com
ServerName grafana.local.cav-telematics.com
DocumentRoot /var/www/html
#ErrorLog ${APACHE_LOG_DIR}/authproxy-error.log
#CustomLog ${APACHE_LOG_DIR}/authproxy-access.log combined
Expand Down Expand Up @@ -42,20 +42,20 @@
ProxyPass / ${GRAFANA_LOCAL_URL}
ProxyPassReverse / ${GRAFANA_LOCAL_URL}
</VirtualHost>
<VirtualHost *:80>
ServerName local.com
<VirtualHost *:8888>
ServerName local.cav-telematics.com
ProxyPreserveHost On
ProxyPass / ${CLIENT_LOCAL_URL} KeepAlive=On
ProxyPassReverse / ${CLIENT_LOCAL_URL}
</VirtualHost>
<VirtualHost *:80>
ServerName ui-service.local.com
<VirtualHost *:8888>
ServerName ui-service.local.cav-telematics.com
ProxyPreserveHost On
ProxyPass / ${UISERVICE_LOCAL_URL} KeepAlive=On
ProxyPassReverse / ${UISERVICE_LOCAL_URL}
</VirtualHost>
<VirtualHost *:80>
ServerName topic-service.local.com
<VirtualHost *:8888>
ServerName topic-service.local.cav-telematics.com
ProxyPreserveHost On
ProxyPass / ${TOPICSERVICE_LOCAL_URL} KeepAlive=On
ProxyPassReverse / ${TOPICSERVICE_LOCAL_URL}
Expand Down
11 changes: 11 additions & 0 deletions telematic_system/telematic_apps/apache2/local.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ubuntu/apache2:latest
RUN a2enmod proxy
RUN a2enmod rewrite
RUN a2enmod proxy_balancer
RUN a2enmod proxy_http
RUN a2enmod headers
RUN touch /etc/apache2/grafana_htpasswd
RUN chmod 777 /etc/apache2/grafana_htpasswd
COPY ports.local.conf /etc/apache2/ports.conf
COPY 000-default.local.conf /etc/apache2/sites-available/000-default.conf
COPY 000-default.local.conf /etc/apache2/sites-enabled/000-default.conf
15 changes: 15 additions & 0 deletions telematic_system/telematic_apps/apache2/ports.local.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 8888

<IfModule ssl_module>
Listen 443
</IfModule>

<IfModule mod_gnutls.c>
Listen 443
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
2 changes: 1 addition & 1 deletion telematic_system/telematic_apps/grafana/grafana.ini
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ serve_from_sub_path = true
; type = mysql
; host = <mysql-db-instance-endpoint>:3306
type = mysql
host = localhost:3306
host = localhost:3307
name = wfd_grafana
user = root
password = root
Expand Down
4 changes: 2 additions & 2 deletions telematic_system/telematic_apps/web_app/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ var verifyToken = (req) => {
//Authorization: 'TOKEN'
const token = req.headers.authorization;
if (token) {
const decodedToken = jwt.verify(token, process.env.SECRET);
if (decodedToken) {
const decodedToken = jwt.verify(token, process.env.SECRET);
if (decodedToken && decodedToken.exp > (new Date().getTime() / 1000)) {
return true;
}
}
Expand Down
Loading

0 comments on commit ebd7abd

Please sign in to comment.