# Development override to mount the frontend source into a node container # and run the React dev server with HMR so you can edit files locally # without rebuilding images. This file is intended to be used together # with the existing docker-compose.yml from the repository. services: image-uploader-frontend: container_name: image-uploader-frontend-dev # For dev convenience nginx needs to be able to bind to port 80 and write the pid file # and we also adjust file permissions on bind-mounted node_modules; run as root in dev. user: root # Build and run a development image that contains both nginx and the # React dev server. nginx will act as a reverse proxy to the dev server # so the app behaves more like production while HMR still works. build: context: ./frontend dockerfile: Dockerfile.dev working_dir: /app # Map host port 3000 to the nginx listener (container:80) so you can open # http://localhost:3000 and see the nginx-served dev site. ports: - "3000:80" volumes: - ./frontend:/app:cached # Keep container node_modules separate so host node_modules doesn't conflict - node_modules:/app/node_modules environment: # Use the backend service name so the dev frontend (running in the same # compose project) can reach the backend via the internal docker network. - CHOKIDAR_USEPOLLING=true - HOST=0.0.0.0 - API_URL=http://image-uploader-backend:5000 - CLIENT_URL=http://localhost:3000 networks: - npm-nw - image-uploader-internal depends_on: - image-uploader-backend image-uploader-backend: container_name: image-uploader-backend-dev build: context: ./backend dockerfile: Dockerfile working_dir: /usr/src/app ports: - "5000:5000" volumes: - ./backend:/usr/src/app:cached - backend_node_modules:/usr/src/app/node_modules environment: - NODE_ENV=development networks: - image-uploader-internal command: [ "npm", "run", "server" ] # The Dockerfile.dev provides a proper CMD that starts nginx and the # react dev server; no ad-hoc command is required here. networks: npm-nw: external: true image-uploader-internal: driver: bridge volumes: node_modules: driver: local backend_node_modules: driver: local