Building a mongodb csv import App
Steps involved:
- Setup your Nodejs application.
- Create Dockerfile’s for each service.
- Define services using the Compose file.
- Run docker-compose to build the application.
Docker and Dockerfile
Key concepts Docker image is a template that is used to create a docker container. Docker container is a instance of docker image containing all the components needed to run.
- docker files may be in project root or other directory. Typically they are named 'dockerfile'.
- Comments may start with # at a line start only
# FROM Creates layers of dependencies like we could build an OS layer.
FROM alpine:latest
# RUN allows us to install linux packages.
RUN apk add — no-cache nodejs npm
WORKDIR /app
# COPY adds files from Docker client’s current directory.
COPY . /app
COPY package.json /app
# RUN allows us to install your application and packages required for it.
RUN npm install
COPY . /app
EXPOSE 8080
# CMD specifies a list of command to run within a Container.
CMD ["node", "app.js"]
mongo in db
Node in docker
- Create App directory
- create docker file Basic docker App using dockerfile