Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
npm-debug.log
coverage
25 changes: 25 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy

on:
push:
branches: [dev]

jobs:
deploy-stage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: akhileshns/heroku-deploy@v3.12.12
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{secrets.HEROKU_APP_NAME}}
heroku_email: ${{secrets.HEROKU_ACCOUNT_EMAIL}}
usedocker: true
stack: "container"
healthcheck: |
"https://"
${{secrets.HEROKU_STAGING_APP_NAME}}
".herokuapp.com/health"
checkstring: "ok"
delay: 60
rollbackonhealthcheckfailed: true
25 changes: 25 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy

on:
push:
branches: [master]

jobs:
deploy-prod:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: akhileshns/heroku-deploy@v3.12.12
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{secrets.HEROKU_APP_NAME}}
heroku_email: ${{secrets.HEROKU_ACCOUNT_EMAIL}}
usedocker: true
stack: "container"
healthcheck: |
"https://"
${{secrets.HEROKU_APP_NAME}}
".herokuapp.com/health"
checkstring: "ok"
delay: 60
rollbackonhealthcheckfailed: true
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.github/
docker-compose.yml
node_modules
dist
coverage
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# # pulling the suitable version of node
FROM node:14.16 as build

# specifying the container app directory
WORKDIR /khushal/src/app

# copy package.json and everything in the directory
COPY package.json ./

RUN npm install

# first dot - the working directory
# second dot - the docker app directory
COPY . .

# build the project
RUN npm run build

# -----------------------------

# Production container

FROM node:14.16
WORKDIR /user/src/app
COPY package.json .
RUN npm install --only=production
COPY --from=build /khushal/src/app/dist ./dist
# COPY --from=build /khushal/src/app/.env ./
CMD npm run start:prod
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.8"
services:
api:
# image: khushalbhardwaj-0111/notary
build:
dockerfile: Dockerfile
context: ./
environment:
NODE_ENV: production
ports:
- "8080:80"
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "notary-api",
"private": true,
"version": "1.0.0",
"version": "1.0.1",
"description": "Notary API",
"license": "MIT",
"scripts": {
Expand All @@ -13,6 +13,8 @@
"start:dev": "nest build --webpack --webpackPath webpack.config.js --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"up": "docker-compose up",
"down": "docker-compose down",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
Expand Down Expand Up @@ -77,6 +79,9 @@
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
"testEnvironment": "node",
"engines": {
"node": "14.x"
}
}
}
16 changes: 8 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ dotenv.config();
declare const module: any;

(async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors();
app.use(helmet());
const app = await NestFactory.create(AppModule);
app.enableCors();
app.use(helmet());

if (module.hot) {
module.hot.accept();
module.hot.dispose(() => app.close());
}
if (module.hot) {
module.hot.accept();
module.hot.dispose(() => app.close());
}

await app.listen(process.env.PORT || 8080);
await app.listen(process.env.PORT || 80);
})();