feat: deploy microservices via docker compose
This commit is contained in:
parent
b51614e5c8
commit
8c7cb6d7e9
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
const (
|
||||
NATS_ACCOUNT_SUBJ_PREFIX = "account-manager.v1."
|
||||
NATS_REQUEST_TIMEOUT = 5 * time.Second
|
||||
NATS_REQUEST_TIMEOUT = 10 * time.Second
|
||||
NATS_MQTT_SUBJECT_PREFIX = "mqtt.usp.v1."
|
||||
NATS_MQTT_ADAPTER_SUBJECT_PREFIX = "mqtt-adapter.usp.v1."
|
||||
NATS_ADAPTER_SUBJECT = "adapter.usp.v1."
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
|
||||
2
deploy/compose/.env.adapter
Normal file
2
deploy/compose/.env.adapter
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
NATS_URL=nats://msg_broker:4222
|
||||
MONGO_URI=mongodb://mongo_usp:27017
|
||||
2
deploy/compose/.env.controller
Normal file
2
deploy/compose/.env.controller
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
NATS_URL=nats://msg_broker:4222
|
||||
MONGO_URI=mongodb://mongo_usp:27017
|
||||
2
deploy/compose/.env.mqtt
Normal file
2
deploy/compose/.env.mqtt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
REDIS_ENABLE=true
|
||||
REDIS_ADDR=redis_usp:6379
|
||||
2
deploy/compose/.env.mqtt-adapter
Normal file
2
deploy/compose/.env.mqtt-adapter
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
NATS_URL=nats://msg_broker:4222
|
||||
MQTT_URL=tcp://mqtt:1883
|
||||
1
deploy/compose/.env.socketio
Normal file
1
deploy/compose/.env.socketio
Normal file
|
|
@ -0,0 +1 @@
|
|||
NATS_URL=nats://msg_broker:4222
|
||||
2
deploy/compose/.env.stomp-adapter
Normal file
2
deploy/compose/.env.stomp-adapter
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
NATS_URL=nats://msg_broker:4222
|
||||
STOMP_SERVER=stomp:61613
|
||||
2
deploy/compose/.env.ws-adapter
Normal file
2
deploy/compose/.env.ws-adapter
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
NATS_URL=nats://msg_broker:4222
|
||||
WS_ADDR=ws
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
services:
|
||||
|
||||
#/* ----------------------------- Message Broker ----------------------------- */
|
||||
nats:
|
||||
msg_broker:
|
||||
image: 'nats:latest'
|
||||
container_name: nats
|
||||
ports:
|
||||
|
|
@ -22,6 +22,8 @@ services:
|
|||
- 8000:8000
|
||||
depends_on:
|
||||
- mongo_usp
|
||||
env_file:
|
||||
- .env.controller
|
||||
networks:
|
||||
usp_network:
|
||||
ipv4_address: 172.16.235.3
|
||||
|
|
@ -37,6 +39,7 @@ services:
|
|||
networks:
|
||||
usp_network:
|
||||
ipv4_address: 172.16.235.4
|
||||
profiles: [controller,adapter]
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
|
|
@ -58,6 +61,8 @@ services:
|
|||
- 8883:8883
|
||||
depends_on:
|
||||
- redis
|
||||
env_file:
|
||||
- .env.mqtt
|
||||
networks:
|
||||
usp_network:
|
||||
ipv4_address: 172.16.235.6
|
||||
|
|
@ -90,6 +95,8 @@ services:
|
|||
container_name: mqtt-adapter
|
||||
depends_on:
|
||||
- mqtt
|
||||
env_file:
|
||||
- .env.mqtt-adapter
|
||||
networks:
|
||||
usp_network:
|
||||
ipv4_address: 172.16.235.9
|
||||
|
|
@ -101,6 +108,8 @@ services:
|
|||
container_name: ws-adapter
|
||||
depends_on:
|
||||
- ws
|
||||
env_file:
|
||||
- .env.ws-adapter
|
||||
networks:
|
||||
usp_network:
|
||||
ipv4_address: 172.16.235.10
|
||||
|
|
@ -111,6 +120,8 @@ services:
|
|||
container_name: stomp-adapter
|
||||
depends_on:
|
||||
- stomp
|
||||
env_file:
|
||||
- .env.stomp-adapter
|
||||
networks:
|
||||
usp_network:
|
||||
ipv4_address: 172.16.235.11
|
||||
|
|
@ -121,6 +132,8 @@ services:
|
|||
container_name: adapter
|
||||
depends_on:
|
||||
- mongo_usp
|
||||
env_file:
|
||||
- .env.adapter
|
||||
networks:
|
||||
usp_network:
|
||||
ipv4_address: 172.16.235.12
|
||||
|
|
@ -129,13 +142,15 @@ services:
|
|||
|
||||
#/* ------------- SocketIO Real Time Communication With Frontend ------------- */
|
||||
socketio:
|
||||
image: 'oktopusp/adapter'
|
||||
image: 'oktopusp/socketio'
|
||||
container_name: socketio
|
||||
ports:
|
||||
- 5000:5000
|
||||
env_file:
|
||||
- .env.socketio
|
||||
networks:
|
||||
usp_network:
|
||||
ipv4_address: 172.16.235.12
|
||||
ipv4_address: 172.16.235.13
|
||||
profiles: [frontend]
|
||||
#/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
|
@ -146,13 +161,13 @@ services:
|
|||
tty: true
|
||||
stdin_open: true
|
||||
volumes:
|
||||
- ../:/app/oktopus
|
||||
command: bash -c "cd /app/oktopus/frontend && npm i && npm run dev"
|
||||
- ../../frontend:/app/
|
||||
command: bash -c "cd /app/ && npm i && npm run dev"
|
||||
ports:
|
||||
- 3000:3000
|
||||
networks:
|
||||
usp_network:
|
||||
ipv4_address: 172.16.235.13
|
||||
ipv4_address: 172.16.235.14
|
||||
profiles: [frontend]
|
||||
#/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
|
@ -163,7 +178,7 @@ services:
|
|||
- 9443:9443
|
||||
networks:
|
||||
usp_network:
|
||||
ipv4_address: 172.16.235.14
|
||||
ipv4_address: 172.16.235.15
|
||||
profiles: [portainer]
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ const addDeviceObj = async(obj, setShowLoading, router, updateDeviceParameters)
|
|||
body: raw
|
||||
};
|
||||
setShowLoading(true)
|
||||
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/add`, requestOptions))
|
||||
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/add`, requestOptions))
|
||||
if (result.status != 200) {
|
||||
if (result.status === 401){
|
||||
router.push("/auth/login")
|
||||
|
|
@ -131,7 +131,7 @@ const deleteDeviceObj = async(obj, setShowLoading, router, updateDeviceParameter
|
|||
body: raw
|
||||
};
|
||||
setShowLoading(true)
|
||||
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/del`, requestOptions))
|
||||
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/del`, requestOptions))
|
||||
if (result.status != 200) {
|
||||
if (result.status === 401){
|
||||
router.push("/auth/login")
|
||||
|
|
@ -481,7 +481,7 @@ const getDeviceParameters = async (raw) =>{
|
|||
body: raw
|
||||
};
|
||||
|
||||
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/parameters`, requestOptions))
|
||||
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/parameters`, requestOptions))
|
||||
if (result.status != 200) {
|
||||
if (result.status === 401){
|
||||
router.push("/auth/login")
|
||||
|
|
@ -505,7 +505,7 @@ const getDeviceParameterInstances = async (raw) =>{
|
|||
body: raw
|
||||
};
|
||||
|
||||
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/instances`, requestOptions))
|
||||
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/instances`, requestOptions))
|
||||
if (result.status != 200) {
|
||||
throw new Error('Please check your email and password');
|
||||
}else if (result.status === 401){
|
||||
|
|
@ -778,7 +778,7 @@ const getDeviceParameterInstances = async (raw) =>{
|
|||
body: raw
|
||||
};
|
||||
|
||||
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/get`, requestOptions))
|
||||
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/get`, requestOptions))
|
||||
if (result.status != 200) {
|
||||
if (result.status === 401){
|
||||
router.push("/auth/login")
|
||||
|
|
@ -1028,7 +1028,7 @@ const getDeviceParameterInstances = async (raw) =>{
|
|||
|
||||
setOpen(false)
|
||||
setShowLoading(true)
|
||||
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/set`, requestOptions))
|
||||
let result = await (await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/set`, requestOptions))
|
||||
if (result.status != 200) {
|
||||
if (result.status === 401){
|
||||
router.push("/auth/login")
|
||||
|
|
@ -1171,7 +1171,7 @@ const getDeviceParameterInstances = async (raw) =>{
|
|||
body: raw
|
||||
};
|
||||
setShowLoading(true)
|
||||
let result = await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/operate`, requestOptions)
|
||||
let result = await fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/operate`, requestOptions)
|
||||
let content = await result.json()
|
||||
if (result.status != 200) {
|
||||
setShowLoading(false)
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ const handleOpen = () => {
|
|||
}
|
||||
|
||||
|
||||
fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/${method}`, requestOptions)
|
||||
fetch(`${process.env.NEXT_PUBLIC_REST_ENPOINT}/device/${router.query.id[0]}/any/${method}`, requestOptions)
|
||||
.then(response => response.text())
|
||||
.then(result => {
|
||||
if (result.status === 401){
|
||||
|
|
|
|||
|
|
@ -13,7 +13,11 @@ import {
|
|||
} from '@mui/material';
|
||||
|
||||
export const OverviewTasksProgress = (props) => {
|
||||
const { value, sx } = props;
|
||||
var { value, sx } = props;
|
||||
var valueRaw;
|
||||
if( value !== undefined) {
|
||||
valueRaw = value.substring(1);
|
||||
}
|
||||
|
||||
return (
|
||||
<Card sx={sx}>
|
||||
|
|
@ -33,7 +37,7 @@ export const OverviewTasksProgress = (props) => {
|
|||
Conexão MQTT
|
||||
</Typography>
|
||||
<Typography variant="h4">
|
||||
{value}ms
|
||||
{valueRaw}
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Avatar
|
||||
|
|
@ -50,7 +54,7 @@ export const OverviewTasksProgress = (props) => {
|
|||
</Stack>
|
||||
<Box sx={{ mt: 3 }}>
|
||||
<LinearProgress
|
||||
value={value}
|
||||
value={80}
|
||||
variant="determinate"
|
||||
/>
|
||||
</Box>
|
||||
|
|
@ -60,6 +64,6 @@ export const OverviewTasksProgress = (props) => {
|
|||
};
|
||||
|
||||
OverviewTasksProgress.propTypes = {
|
||||
value: PropTypes.number.isRequired,
|
||||
value: PropTypes.string.isRequired,
|
||||
sx: PropTypes.object
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user