Skip to content

Commit

Permalink
feat: added docker stuff
Browse files Browse the repository at this point in the history
- DockerFile to compile locally
- the server as normal and tls
- yaml files
  • Loading branch information
Bugs5382 committed Feb 25, 2024
1 parent 187c3c1 commit f1a4140
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 9 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ FROM node:20.11.0-alpine3.19
# set working directory in the image
WORKDIR /home/node/app

## copy over server
COPY docker .
## copy files over
COPY docker/package.json .
COPY docker/server.js .
COPY docker/tls.server.js .
COPY certs certs

## Run
RUN npm install
RUN npm i node-hl7-server

# EXPOSE
EXPOSE 3000

# COMMAND
CMD ["npm", "run", "server"]
EXPOSE 3000
4 changes: 2 additions & 2 deletions docker/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "docker-hl7-server",
"version": "1.0.0",
"main": "server.js",
"private": true,
"scripts": {
"server": "node server.js"
"server": "node server.js",
"server:tls": "node tls.server.js"
},
"description": "Simple Server running on Docker",
"author": "Shane Froebel",
Expand Down
32 changes: 32 additions & 0 deletions docker/tls.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { Server } = require('node-hl7-server')
const fs= require('node:fs')
const path = require('node:path')

const server = new Server({
bindAddress: 'localhost',
tls: {
key: fs.readFileSync(path.join('certs/', 'server-key.pem')),
cert: fs.readFileSync(path.join('certs/', 'server-crt.pem')),
rejectUnauthorized: false
}
})

const inbound = server.createInbound({ port: 3000 }, async (req, res) => {
await res.sendResponse('AA')
})

inbound.on('client.close', () => {
console.log('Client Disconnected')
})

inbound.on('client.connect', () => {
console.log('Client Connected')
})

inbound.on('data.raw', (data) => {
console.log('Raw Data:', data)
})

inbound.on('listen', () => {
console.log('Ready to Listen for Messages')
})
38 changes: 38 additions & 0 deletions docker/yaml/server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: v1
kind: Service
metadata:
name: hl7-server
namespace: hl7-server
spec:
ports:
- name: 6000-tcp
port: 6000
protocol: TCP
targetPort: 3000
selector:
app: hl7-server
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hl7-server
namespace: hl7-server
spec:
selector:
matchLabels:
app: hl7-server
replicas: 1
template:
metadata:
labels:
app: hl7-server
spec:
containers:
- name: hl7-server
command: ["npm"]
args: ["run", "server"]
image: docker-node-hl7-server:latest
ports:
- containerPort: 3000
imagePullPolicy: IfNotPresent
38 changes: 38 additions & 0 deletions docker/yaml/tls.server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: v1
kind: Service
metadata:
name: tls-hl7-server
namespace: hl7-server
spec:
ports:
- name: 6001-tcp
port: 6001
protocol: TCP
targetPort: 3000
selector:
app: tls-hl7-server
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tls-hl7-server
namespace: hl7-server
spec:
selector:
matchLabels:
app: tls-hl7-server
replicas: 1
template:
metadata:
labels:
app: tls-hl7-server
spec:
containers:
- name: tls-hl7-server
command: ["npm"]
args: ["run", "server:tls"]
image: docker-node-hl7-server:latest
ports:
- containerPort: 3000
imagePullPolicy: IfNotPresent
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"clean": "rm -rf coverage docs lib temp",
"build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && tsc -p tsconfig.types.json && ./bin/build-types.sh",
"build:watch": "tsc -p tsconfig.esm.json -w",
"docker:build": "docker build -t docker-hl7-server:latest .",
"docker:build": "docker build -t docker-node-hl7-server:latest .",
"npm:lint": "npmPkgJsonLint .",
"lint": "npm run npm:lint && ts-standard | snazzy",
"lint:fix": "npm run npm:lint . && ts-standard --fix | snazzy",
Expand Down

0 comments on commit f1a4140

Please sign in to comment.