I was thinking about a solution in development to have node_modules in my Docker containers and on my host machine to have Intelisense on VSCode for Typescript.
Is this solution (which works) a good one? With this way of doing things, I can install my dependencies directly in Docker.
The advantage of Docker remains the same, despite the fact that it’s less isolated because of the volumes. I don’t have to install NodeJS locally, and my production environment remains the same (same Docker images).
—
Dockerfile:
FROM arm64v8/node:20.17-alpine
WORKDIR /app
ARG NODE_ENV=development
ENV PATH=/app/node_modules/.bin:$PATH
EXPOSE 4321
ENTRYPOINT ["yarn", "workspace", "web", "dev"]
docker-compose.yml:
services:
install-deps:
image: arm64v8/node:20.17-alpine
entrypoint: ./docker-entrypoint.sh
profiles: ["install-deps"]
build:
context: .
working_dir: /app
volumes:
- ./:/app
web:
build:
context: ./
dockerfile: apps/web/Dockerfile
restart: unless-stopped
volumes:
- ./apps/web:/app/apps/web
- ./node_modules:/app/node_modules
- ./turbo.json:/app/turbo.json
- ./package.json:/app/package.json
- ./yarn.lock:/app/yarn.lock
The command to install dependencies:
docker compose run --rm install-deps yarn
1