Skip to content
This repository has been archived by the owner on Apr 9, 2022. It is now read-only.

Commit

Permalink
Add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
evantahler committed Jun 15, 2021
1 parent 896f380 commit 09d1e02
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 9 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:14
WORKDIR /app

ENV PORT 8080

COPY package*.json .
RUN npm install

COPY . .
RUN npm run build

CMD [ "node", "dist/index.js" ]
EXPOSE $PORT/tcp
35 changes: 28 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
"build": "tsc",
"lint": "prettier --check src",
"watch": "tsc --watch",
"start": "node ./dist/index.js"
"start": "node ./dist/index.js",
"test": "npm run lint"
},
"dependencies": {
"@types/node": "*",
"typescript": "4.2.4"
"typescript": "4.3.2"
},
"devDependencies": {
"prettier": "2.3.1"
}
}
14 changes: 14 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ function parseIp(req: http.IncomingMessage) {
);
}

function exit() {
console.log("*** Bye! ***");
process.exit(0);
}

process.on("SIGINT", () => exit());
process.on("SIGTERM", () => exit());
process.on("SIGHUP", () => exit());
process.on("SIGUSR2", () => exit());

const server = http.createServer(handle);
server.listen(port);

console.log(`*** Redirector up and running ***`);
console.log({ port, destination, http_code });
console.log("***");
console.log("");

0 comments on commit 09d1e02

Please sign in to comment.