You want your servers to run on docker and you want a consistent developer experience locally.
Great!
- In your Dockerfile, COPY your source files as normal.
- Create a docker-compose.yml file that mounts a volume from the host machine to the source directory (overriding the COPY from the dockerfile). Override the
command
inside docker-compose.yml as needed.
Build normally for production.
Use docker-compose up --build
for development on your host machine.
Example:
Dockerfile
FROM node:alpine WORKDIR /api COPY package.json . COPY yarn.lock . RUN yarn install COPY . /api CMD ["node", "src/index.js"]
docker-compose.yml
version: '3.6' services: api: build: . volumes: - ./src:/api/src command: npx nodemon src/index.js
Top comments (0)