Skip to content

Commit 8cc39da

Browse files
committed
dockerized
1 parent b40fa06 commit 8cc39da

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
node_modules
2+
\.DS_Store

Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node:8
2+
3+
# Create app directory
4+
WORKDIR /nile-instance
5+
6+
COPY package*.json ./
7+
8+
RUN npm install
9+
10+
COPY . .
11+
12+
EXPOSE 3334
13+
14+
CMD [ "npm", "start" ]

src/index.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const server = require('http').createServer(handleRequest)
77
const Httpdispatcher = require('httpdispatcher')
88
var dispatcher = new Httpdispatcher()
99

10+
const PORT = 3334
11+
1012
function handleRequest (request, response) {
1113
try {
1214
dispatcher.dispatch(request, response)
@@ -16,11 +18,13 @@ function handleRequest (request, response) {
1618
}
1719

1820
const sqlite3 = require('sqlite3').verbose()
19-
const db = new sqlite3.Database('../var/instance.db')
21+
const path = require('path')
22+
const dbPath = path.resolve(__dirname, '../var/instance.db')
23+
const db = new sqlite3.Database(dbPath)
2024

2125
// Initialize an websocket server
2226
const wsServer = require('socket.io')(server)
23-
server.listen(3334)
27+
server.listen(PORT)
2428

2529
// initialize ipfs
2630
const IPFS = require('ipfs')
@@ -54,3 +58,5 @@ wsServer.on('connection', (socket) => {
5458
})
5559

5660
instance.loadListeners(http.ID, dispatcher)
61+
62+
console.log("Server listening on port:", PORT);

0 commit comments

Comments
 (0)