A progressive Node.js framework for building efficient and scalable server-side applications.
Nest framework TypeScript starter repository.
Replace the string 'project-name' in all files of the project with your own project name. (For example with the search/replace function from visual studio code)
Files to edit:
- docker-compose.yml
- docker-compose.dev.yml
- docker-compose.test.yml
- docker-compose.prod.yml
- prod.env
- dev.env
- test.env
- test.docker.env
Important to avoid docker container naming conflicts!
Set up the environment variable COMPOSE_FILE to avoid the 'Found orphan containers' warning:
MacOS:
COMPOSE_FILE=docker-compose.prod.yml:docker-compose.dev.yml:docker-compose.test.yml
Windows:
COMPOSE_FILE=docker-compose.prod.yml;docker-compose.dev.yml;docker-compose.test.yml
$ yarn
$ yarn build
# create docker network for database connection
$ docker network create project-name-network-dev
# start the app and database in docker containers
$ docker-compose -f 'docker-compose.dev.yml' up
# start first migration to create the db tables
$ yarn db:migrate:dev
# start test database in docker container
$ docker-compose -f 'docker-compose.test.yml' up
# start first migration to create the db tables
$ yarn db:migrate:test
# unit tests
$ yarn test
# watch mode
$ yarn test:watch
# e2e tests
$ yarn test:e2e
# test coverage
$ yarn test:cov
# start docker containers (app, dev + test)
$ yarn docker:up:hidden
# start first migration to create the db tables
$ yarn docker:db:migrate
# execute tests in the docker container
$ yarn docker:test
- To create a docker image + container with the app & database.
# create network to connect the app with the db
$ docker network create project-name-network
# set the env variables for the docker compose file (I used github secrets in the github actions pipeline)
# build the docker image, create & run the app/db container in detached mode (background)
$ docker-compose -f 'docker-compose.prod.yml' up -d
# init tables with migration
$ docker-compose exec app yarn db:migrate:prod
- To update the docker image and start the new docker container
$ docker build -t project-name .
$ docker-compose up -d
- To run new migrations
# start migrations
$ docker-compose exec app yarn db:migrate:prod
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.