mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
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:
@@ -0,0 +1,6 @@
|
|||||||
|
node_modules
|
||||||
|
README.md
|
||||||
|
LICENSE.txt
|
||||||
|
Dockerfile
|
||||||
|
.vscode
|
||||||
|
.gitignore
|
||||||
+29
@@ -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"]
|
||||||
@@ -23,8 +23,6 @@ $ npm run start:dev
|
|||||||
$ npm run build
|
$ npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Test
|
## Test
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -36,12 +34,33 @@ $ npm run test:cov
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Web interface
|
## Web interface
|
||||||
|
|
||||||
See [public-pool-ui](https://github.com/benjamin-wilson/public-pool-ui)
|
See [public-pool-ui](https://github.com/benjamin-wilson/public-pool-ui)
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
Install pm2 (https://pm2.keymetrics.io/)
|
Install pm2 (https://pm2.keymetrics.io/)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ pm2 start dist/main.js
|
$ 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
|
||||||
|
```
|
||||||
|
|||||||
Generated
+1
-1
@@ -45,7 +45,7 @@
|
|||||||
"@types/cron": "^2.0.1",
|
"@types/cron": "^2.0.1",
|
||||||
"@types/express": "^4.17.13",
|
"@types/express": "^4.17.13",
|
||||||
"@types/jest": "29.5.1",
|
"@types/jest": "29.5.1",
|
||||||
"@types/node": "18.16.12",
|
"@types/node": "^18.16.12",
|
||||||
"@types/node-telegram-bot-api": "^0.61.6",
|
"@types/node-telegram-bot-api": "^0.61.6",
|
||||||
"@types/supertest": "^2.0.11",
|
"@types/supertest": "^2.0.11",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@
|
|||||||
"@types/cron": "^2.0.1",
|
"@types/cron": "^2.0.1",
|
||||||
"@types/express": "^4.17.13",
|
"@types/express": "^4.17.13",
|
||||||
"@types/jest": "29.5.1",
|
"@types/jest": "29.5.1",
|
||||||
"@types/node": "18.16.12",
|
"@types/node": "^18.16.12",
|
||||||
"@types/node-telegram-bot-api": "^0.61.6",
|
"@types/node-telegram-bot-api": "^0.61.6",
|
||||||
"@types/supertest": "^2.0.11",
|
"@types/supertest": "^2.0.11",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||||
|
|||||||
+7
-2
@@ -25,7 +25,6 @@ async function bootstrap() {
|
|||||||
cert: readFileSync(`${currentDirectory}/secrets/cert.pem`),
|
cert: readFileSync(`${currentDirectory}/secrets/cert.pem`),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter(options));
|
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter(options));
|
||||||
@@ -38,10 +37,15 @@ async function bootstrap() {
|
|||||||
forbidUnknownValues: true
|
forbidUnknownValues: true
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
process.on('SIGINT', () => {
|
||||||
|
console.log(`Stopping services`);
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
app.enableCors();
|
app.enableCors();
|
||||||
useContainer(app.select(AppModule), { fallbackOnErrors: true });
|
useContainer(app.select(AppModule), { fallbackOnErrors: true });
|
||||||
|
|
||||||
|
|
||||||
//Taproot
|
//Taproot
|
||||||
bitcoinjs.initEccLib(ecc);
|
bitcoinjs.initEccLib(ecc);
|
||||||
|
|
||||||
@@ -50,4 +54,5 @@ async function bootstrap() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user