Dockerized Node.js project starter using following stack:
# Clone repo:
git clone [email protected]:piotrkabacinski/node-starter.git --depth 1
# Create .env file based on template file:
cp .env.template .env
nvm use
npm i
docker-compose build
# Run migrations:
docker-compose run --rm app npm run migration:deploy
# Run server:
docker-compose up
When installing new dependencies locally do it within container as well:
docker-compose run --rm app npm i
If using VS Code try prisma extension for better DX.
When changing prisma's schema (src/db/schema.prisma
) run migration command:
# Create and run migration:
npm run migration <migration name>
# Apply migrations on production server after deploy:
npm run migration:deploy
docker-compose run --rm app npm t
docker exec -it <container name prefix>_db_1 psql -U postgres
\l # List all data bases
\c <db name> # Connect to DB
\dt # Show data base tables
docker exec -it <container name prefix>_redis_1 redis-cli
For manual tests of Todo API example you can import Insomnia workspace from insomnia.json
.
App is configured for Heroku environment. See Heroku.md file for deployment details.