Browse Source

Add docker

main
Haris Razis 4 years ago
parent
commit
f80f115e27
No known key found for this signature in database GPG Key ID: 86A4D290ED03FAB4
  1. 1
      .gitignore
  2. 11
      client/Dockerfile
  3. 2
      client/client.sh
  4. 1861
      client/package-lock.json
  5. 10
      client/package.json
  6. 2
      client/src/class/ClientService.ts
  7. 2
      client/src/class/ClientSocket.ts
  8. 1
      database/database.sh
  9. 13
      server/Dockerfile
  10. 1111
      server/package-lock.json
  11. 12
      server/package.json
  12. 2
      server/server.sh
  13. 1
      server/src/class/ServerSocket.ts

1
.gitignore

@ -1,4 +1,5 @@
build/ build/
creds.ts
# Logs # Logs
logs logs

11
client/Dockerfile

@ -0,0 +1,11 @@
FROM node:latest
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
ENTRYPOINT npm run start

2
client/client.sh

@ -0,0 +1,2 @@
docker build -t xrazis/client .
docker run -d xrazis/client

1861
client/package-lock.json

File diff suppressed because it is too large

10
client/package.json

@ -1,14 +1,14 @@
{ {
"name": "Anchiale-sensor", "name": "Anchiale-client",
"version": "1.0.0", "version": "1.0.0",
"description": "Client for taking a temperature measure", "description": "Client for taking a temperature measure",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start:build": "tsc -w", "start:build": "tsc -w",
"start:run": "node build/index.js", "start:run": "node build/index.js",
"dev": "nodemon build/index.js", "start": "concurrently npm:start:*",
"test": "concurrently npm:start:build npm:dev", "develop": "nodemon build/index.js",
"start": "concurrently npm:start:*" "dev": "concurrently npm:start:build npm:develop"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -26,8 +26,10 @@
"@types/socket.io-client": "^1.4.34", "@types/socket.io-client": "^1.4.34",
"@types/uuid": "^8.3.0", "@types/uuid": "^8.3.0",
"chalk": "^3.0.0", "chalk": "^3.0.0",
"concurrently": "^5.3.0",
"nodemon": "^2.0.6", "nodemon": "^2.0.6",
"socket.io-client": "^3.0.0", "socket.io-client": "^3.0.0",
"typescript": "^4.0.5",
"uuid": "^8.3.1" "uuid": "^8.3.1"
} }
} }

2
client/src/class/ClientService.ts

@ -19,6 +19,6 @@ export class ClientService {
tempTestService(): void { tempTestService(): void {
setInterval(() => { setInterval(() => {
this.clientSocket.sendTemp(this.uuid, this.sensor.takeTestMeasure); this.clientSocket.sendTemp(this.uuid, this.sensor.takeTestMeasure);
}, 1000); }, 3000);
} }
} }

2
client/src/class/ClientSocket.ts

@ -10,7 +10,7 @@ export class ClientSocket {
} }
private initSocket(): void { private initSocket(): void {
this.socket = io(this.path); this.socket = io(this.path, { transports: ['websocket'] });
console.log(chalk.yellow('Initialized socket...')); console.log(chalk.yellow('Initialized socket...'));
} }

1
database/database.sh

@ -0,0 +1 @@
docker run -d --name influxdb -p 8086:8086 quay.io/influxdb/influxdb:v2.0.1

13
server/Dockerfile

@ -0,0 +1,13 @@
FROM node:latest
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
ENTRYPOINT npm run start

1111
server/package-lock.json

File diff suppressed because it is too large

12
server/package.json

@ -1,14 +1,14 @@
{ {
"name": "Anchiale-broker", "name": "Anchiale-server",
"version": "1.0.0", "version": "1.0.0",
"description": "Broker for managing incoming client temperatures", "description": "Broker for managing incoming client temperatures",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start:build": "tsc -w", "start:build": "tsc -w",
"start:run": "node build/index.js", "start:run": "node build/index.js",
"dev": "nodemon build/index.js", "start": "concurrently npm:start:*",
"test": "concurrently npm:start:build npm:dev", "develop": "nodemon build/index.js",
"start": "concurrently start:*" "dev": "concurrently npm:start:build npm:develop"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -26,7 +26,9 @@
"@types/node": "^14.14.7", "@types/node": "^14.14.7",
"@types/socket.io": "^2.1.11", "@types/socket.io": "^2.1.11",
"chalk": "^3.0.0", "chalk": "^3.0.0",
"concurrently": "^5.3.0",
"nodemon": "^2.0.6", "nodemon": "^2.0.6",
"socket.io": "^3.0.1" "socket.io": "^3.0.1",
"typescript": "^4.0.5"
} }
} }

2
server/server.sh

@ -0,0 +1,2 @@
docker build -t xrazis/server .
docker run -d -p 3000:3000 xrazis/server

1
server/src/class/ServerSocket.ts

@ -23,6 +23,7 @@ export class ServerSocket {
private initSocket(): void { private initSocket(): void {
this.io = new Server(this.port, { this.io = new Server(this.port, {
path: this.path, path: this.path,
transports: ['websocket'],
}); });
console.log(chalk.yellow('Initialized server...')); console.log(chalk.yellow('Initialized server...'));
} }

Loading…
Cancel
Save