Skip to content

Commit

Permalink
chore: add Dockerfile for quick setup (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmstss authored Sep 4, 2024
1 parent 0a221a9 commit 721a32e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/auto-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ jobs:

- name: Run e2e tests
run: npm run test:e2e

- name: Build Docker image
run: cp .env.example .env && docker build -t sectester-js-demo .
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
###################
# BUILDER
###################

FROM node:18-alpine AS build

WORKDIR /usr/src/app

# Copy and build NestJS server project
COPY --chown=node:node package*.json ./
COPY --chown=node:node tsconfig.build.json ./
COPY --chown=node:node tsconfig.json ./
COPY --chown=node:node nest-cli.json ./
COPY --chown=node:node .env ./
COPY --chown=node:node src ./src

ENV NPM_CONFIG_LOGLEVEL=error
RUN npm ci --no-audit
RUN npm run build
RUN npm run migration:up
RUN npm prune --production

USER node

###################
# PRODUCTION
###################

FROM node:18-alpine AS production

WORKDIR /usr/src/app

COPY --chown=node:node .env ./
COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/app/package*.json ./
COPY --chown=node:node --from=build /usr/src/app/test.db ./
COPY --chown=node:node --from=build /usr/src/app/dist ./dist

CMD ["npm", "run", "start:prod"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ Finally, perform this command in terminal to run the application:
$ npm start
```

_Note_: Alternatively, you can quickly run the SecTester SDK Demo app using Docker:

```bash
docker build -t sectester-js-demo-image . && docker run --name sectester-js-demo -p 3000:3000 -d sectester-js-demo-image
```

While having the application running, open a browser and type `http://localhost:3000/api`, and hit enter.
You should see the Swagger UI page for that application that allows you to test the RESTFul CRUD API, like in the following screenshot:

Expand Down

0 comments on commit 721a32e

Please sign in to comment.