#Need Help with Hot Reloading in a Dockerized NestJS App
5 messages · Page 1 of 1 (latest)
Sure :
Here is my DockerFile :
FROM node:20.10.0
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy package.json and package-lock.json (or yarn.lock)
COPY package*.json ./
# Install app dependencies
RUN npm ci
# Bundle app source inside the Docker image
COPY . .
# Rebuild bcrypt for the current platform
RUN npm rebuild bcrypt --build-from-source
# Build the application
RUN npm run build
# Your app binds to port 3000 (or the port your app uses)
EXPOSE 3000
# Define the command to run your app (adjust as necessary based on your npm scripts)
CMD ["npm", "run", "start:dev"]
and My docker-compose.yml:
version: '3.8'
services:
# PostgreSQL Database Service
postgres:
image: postgres:latest
ports:
- "5432:5432"
environment:
POSTGRES_USER: username
POSTGRES_PASSWORD: password
POSTGRES_DB: erd
volumes:
- postgres-data:/var/lib/postgresql/data
# NestJS Backend Service
nestjs-backend:
build: ./match-backend
ports:
- "3000:3000"
environment:
DB_HOST: postgres
DB_PORT: 5432
DB_USERNAME: username
DB_PASSWORD: password
DB_DATABASE: erd
depends_on:
- postgres
env_file:
- ./match-backend/.env
# Kong API Gateway Service
kong:
image: kong:2.8.1
environment:
KONG_DATABASE: "off"
KONG_DECLARATIVE_CONFIG: /etc/kong/kong.yml
ports:
- "8000:8000" #HTTP TRAFFIC
- "8443:8443" #HTTPS
- "8001:8001" # ADMIN APP
- "8444:8444"
depends_on:
- nestjs-backend
volumes:
- ./match-backend/etc/kong:/etc/kong
command: ["kong", "start", "--vv"]
volumes:
postgres-data:
You're missing volume binds in your nestjs-backend compose service. See https://docs.docker.com/language/nodejs/develop/#update-your-compose-file-for-development
(the volumes: part, e.g.
volumes:
- ./src:/usr/src/app/src
)
Thanks for your help!
Adding those volume binds to my docker-compose.yml did the trick.
it was exactly what I needed to solve this issue.