Skip to content

Commit 40c684b

Browse files
committed
Prepare for container
1 parent d28379a commit 40c684b

File tree

6 files changed

+49
-20
lines changed

6 files changed

+49
-20
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
npm-debug.log
3+
.env

.npmrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
@fails-components:registry=https://npm.pkg.github.com
2-
registry=https://registry.npmjs.org
2+
registry=https://registry.npmjs.org
3+
//npm.pkg.github.com/:_authToken=${GH_TOKEN}

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM node:14
2+
3+
ARG ENV
4+
ARG GH_TOKEN
5+
6+
WORKDIR /usr/src/noteshandler
7+
8+
COPY package*.json ./
9+
COPY .npmrc ./
10+
11+
#debug
12+
RUN if [ "$ENV" = "debug" ] ; then npm install ; else npm ci --only=production; fi
13+
14+
COPY . .
15+
16+
EXPOSE 8080
17+
18+
CMD [ "node", "src/server.js" ]

package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
"uuid": "^8.3.2",
4949
"@socket.io/redis-adapter": "^7.0.0",
5050
"cron": "^1.8.2",
51-
"@fails-components/security": "^0.0.0",
52-
"@fails-components/config": "^0.0.0",
51+
"@fails-components/security": ">=0.0.1",
52+
"@fails-components/config": ">=0.0.2",
5353
"mongodb": "^3.6.9",
5454
"redis": "^3.1.2",
55-
"socket.io": "^4.1.2"
55+
"socket.io": "^4.1.3"
5656
},
5757
"nodemonConfig": {
5858
"ignore": [

src/server.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const initServer = async () => {
3434
const cfg = new FailsConfig()
3535

3636
// this should be read only replica
37-
const redisclient = redis.createClient({
37+
const redisclient = redis.createClient(cfg.redisPort(), cfg.redisHost(), {
3838
detect_buffers: true /* required by notes connection */
3939
})
4040

@@ -80,7 +80,11 @@ const initServer = async () => {
8080
}
8181
}
8282

83-
const ioIns = new Server(server, { cors: cors })
83+
const ioIns = new Server(server, {
84+
cors: cors,
85+
path: '/notes.io',
86+
serveClient: false
87+
})
8488
const notepadio = ioIns.of('/notepads')
8589
const screenio = ioIns.of('/screens')
8690
const notesio = ioIns.of('/notes')
@@ -113,7 +117,10 @@ const initServer = async () => {
113117
return next(new Error('no Connection possible'))
114118
}) // this should not connect to screen
115119

116-
server.listen(cfg.getPort('notes'), cfg.getHost(), function () {
120+
let port = cfg.getPort('notes')
121+
if (port === 443) port = 8080 // we are in production mode inside a container
122+
123+
server.listen(port, cfg.getHost(), function () {
117124
console.log(
118125
'Failsserver listening at http://%s:%s',
119126
server.address().address,

0 commit comments

Comments
 (0)