feat: add docker (#6)

* misc: improve match version of types/node

* feat: improve stop with sigint signal

* feat: add docker

* feat: add docker in readme
This commit is contained in:
Jeremy Chabernaud
2023-11-15 15:33:05 -05:00
committed by GitHub
parent a1197fc77e
commit a10aa9c52f
6 changed files with 65 additions and 6 deletions
+6
View File
@@ -0,0 +1,6 @@
node_modules
README.md
LICENSE.txt
Dockerfile
.vscode
.gitignore
+29
View File
@@ -0,0 +1,29 @@
############################
# Docker build environment #
############################
FROM node:18.16.1-bookworm AS build
WORKDIR /build
COPY . .
RUN npm i
RUN npm run build
############################
# Docker final environment #
############################
FROM node:18.16.1-bookworm
EXPOSE 3333
EXPOSE 3334
EXPOSE 8332
WORKDIR /public-pool
COPY --from=build /build .
COPY .env.example .env
CMD ["/usr/local/bin/node", "dist/main"]
+21 -2
View File
@@ -23,8 +23,6 @@ $ npm run start:dev
$ npm run build
```
## Test
```bash
@@ -36,12 +34,33 @@ $ npm run test:cov
```
## Web interface
See [public-pool-ui](https://github.com/benjamin-wilson/public-pool-ui)
## Deployment
Install pm2 (https://pm2.keymetrics.io/)
```bash
$ pm2 start dist/main.js
```
## Docker
Build container:
```bash
$ docker build -t public-pool .
```
Run container (with default configuration):
```bash
$ docker container run --name public-pool --rm -p 3333:3333 -p 3334:3334 -p 8332:8332 public-pool
```
Run container (with custom configuration):
```bash
$ docker container run --name public-pool --rm -p 3333:3333 -p 3334:3334 -p 8332:8332 -v .env:.env public-pool
```
+1 -1
View File
@@ -45,7 +45,7 @@
"@types/cron": "^2.0.1",
"@types/express": "^4.17.13",
"@types/jest": "29.5.1",
"@types/node": "18.16.12",
"@types/node": "^18.16.12",
"@types/node-telegram-bot-api": "^0.61.6",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
+1 -1
View File
@@ -56,7 +56,7 @@
"@types/cron": "^2.0.1",
"@types/express": "^4.17.13",
"@types/jest": "29.5.1",
"@types/node": "18.16.12",
"@types/node": "^18.16.12",
"@types/node-telegram-bot-api": "^0.61.6",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
+7 -2
View File
@@ -25,7 +25,6 @@ async function bootstrap() {
cert: readFileSync(`${currentDirectory}/secrets/cert.pem`),
}
};
}
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter(options));
@@ -38,10 +37,15 @@ async function bootstrap() {
forbidUnknownValues: true
}),
);
process.on('SIGINT', () => {
console.log(`Stopping services`);
process.exit(0);
});
app.enableCors();
useContainer(app.select(AppModule), { fallbackOnErrors: true });
//Taproot
bitcoinjs.initEccLib(ecc);
@@ -50,4 +54,5 @@ async function bootstrap() {
});
}
bootstrap();