Skip to content

Instantly share code, notes, and snippets.

@Sanjay007
Last active August 20, 2021 04:17
Show Gist options
  • Save Sanjay007/ed553b04e3e67e60c6033e4fbb369b93 to your computer and use it in GitHub Desktop.
Save Sanjay007/ed553b04e3e67e60c6033e4fbb369b93 to your computer and use it in GitHub Desktop.
Node JS Docker Example With MongoDB

Dockerfile

FROM node:latest

RUN mkdir -p /usr/src/app

WORKDIR /usr/src/app

COPY package.json /usr/src/app

RUN npm install

COPY . /usr/src/app

EXPOSE 9000

CMD ['node', 'app.js']

RUN npm install -g nodemon

CMD ["node","server.js"]

docker-compose.yml

version: "2" services: app: container_name: app restart: always build: . ports: - "9000:9000" links: - mongo mongo: container_name: mongo image: mongo #volumes: # - ./data:/data/db ports: - "27017:27017"

Have a look at the Article Published on Dockerizing Nodejs MongoDB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment