Coder Social home page Coder Social logo

docker-nestjs-starter's Introduction

Runnig NestJs in a Docker Container

This is a Nest Js project configured for use with Docker

Installation

$ npm install

Ensure also that Docker is installed on your work station

Running the app using node server (the normal way)

# development
$ npm run start:dev
or
nest start

# Debug/watch
$ npm run start:debug

# production
$ npm run build:prod
$ npm start

Setting up the app for use with Docker

  1. Add Dockerfile
  2. Add docker-compose.yml
  3. Add unnecessary files to .gitignore
  4. Add .dockerignore and include the unnecessary files
  5. Add nodemon-docker-debug.json
  6. Add "debug": "nodemon -L --config nodemon-docker-debug.json" script to package.json
  7. Configure VS Code for debugging the node js app with a container

Using Docker

# Build the image
$ docker build -t docker-nest-js:v1.0 .

# Run the image interactively
$ docker run -it -p 3000:3000 docker-nest-js:v1.0

Using Docker Compose

# Build the docker image
$ docker-compose build

# Start and login to the container
$ docker-compose up -d
$ docker-compose exec app sh

Other useful Docker commands

# Get the container ID
$ docker ps

# View logs
$ docker logs <container id>

# Enter the container (In alpine, use sh because bash is not installed by default)
$ docker exec -it <container id> /bin/sh

Testing

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Resources

Tutorial: https://qiita.com/rema424/items/36475ea7379e0d9c5972
Best practices: https://github.com/docker/docker-bench-security

License

MIT licensed

docker-nestjs-starter's People

Contributors

alexsasharegan avatar allenfang avatar alsoicode avatar amitport avatar bashleigh avatar beeman avatar ben-webantic avatar blazeu avatar denpalrius avatar dependabot[bot] avatar e-watson avatar elylucas avatar fanybook avatar jajaperson avatar kamilmysliwiec avatar mchelen avatar progral avatar renovate-bot avatar rpihlak avatar rubencodeforges avatar schinvendy avatar yurykozhenov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.