Skip to content

Commit

Permalink
Add Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
thgh committed Jul 14, 2023
1 parent 950f2e2 commit 972512d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Run `npm run build` before `npm run docker`
/*
!/dist
!/package*.json
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:18-alpine

WORKDIR /app

COPY package*.json ./

RUN npm install --production

COPY dist .

ENTRYPOINT ["node"]
CMD ["srv/index.js"]
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"watch": "tsc -p ./ -w",
"start": "npm run watch & nodemon dist/srv/index.js",
"fix": "prettier --write .",
"docker": "docker build -t thgh/tunnelmole .",
"docker:push": "docker push thgh/tunnelmole",
"docker:run": "docker run -it -e PORT=80 -e TUNNELMOLE_API_KEYS=example-only-delete-in-production -p 80:80 tunnelmole",
"start-prod": "node dist/srv/index.js"
},
"author": "",
Expand Down
4 changes: 4 additions & 0 deletions srv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,7 @@ const interval = setInterval(function ping() {
wss.on("close", function close() {
clearInterval(interval);
});

// Listen for termination signals allows Ctrl+C in docker run
process.on("SIGINT", () => process.exit(0));
process.on("SIGTERM", () => process.exit(0));

0 comments on commit 972512d

Please sign in to comment.