Skip to content

Commit

Permalink
fix websocket server running in dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
lakhoune committed Jun 18, 2021
1 parent 0007200 commit b623488
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ COPY package*.json ./
USER node
RUN npm install
COPY --chown=node:node . .
EXPOSE 1234
CMD [ "npm", "start" ]
10 changes: 5 additions & 5 deletions bin/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const http = require('http')
const wss = new WebSocket.Server({ noServer: true })
const setupWSConnection = require('./utils.js').setupWSConnection

const host = process.env.HOST || 'localhost'
const port = process.env.PORT || 1234
const host = process.env.HOST || 'localhost';
const port = process.env.PORT || 1234;

const server = http.createServer((request, response) => {
response.writeHead(200, { 'Content-Type': 'text/plain' })
Expand All @@ -29,6 +29,6 @@ server.on('upgrade', (request, socket, head) => {
wss.handleUpgrade(request, socket, head, handleAuth)
})

server.listen({ host, port })

console.log(`running at '${host}' on port ${port}`)
server.listen(port, () => {
console.log(`running at '${host}' on port ${port}`);
});

0 comments on commit b623488

Please sign in to comment.