Dockerfile And docker compose:
- https://medium.com/@madhukaudantha/dockerize-microservice-3d7562ffcda3
- https://dzone.com/articles/microservices-an-example-with-docker-go-and-mongod
- https://github.com/mmorejon/microservices-docker-go-mongodb/blob/master/docker-compose.yml
Node image associated with linux system. Thats why no need to add ubuntu/debien system
Docker and docker need to install seperately
From: as a base image
RUN: this command run during image creation
CMD: this commnad run when container create from image
Volume:
Expose:
ENV: to set the environment variable
Docker compose.yml file example of winstone backend service
version: "3"
services:
kupi-backend-dev:
build:
context: .
dockerfile: Dockerfile.development
ports:
- "8080:8080"
environment:
- PORT=8080
- MAIL_CONFIG_PATH=/etc/mail-config/config
volumes:
- ./src:/usr/src/app
- /usr/src/app/node_modules
- ./local/mail-config:/etc/mail-config
- ./local/keydb:/etc/keydb
Dockerfile.development file of winsotne backend service
FROM node:carbon
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install sqlite3 for holding client credentials
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install -y sqlite3 libsqlite3-dev
RUN mkdir /etc/keydb
RUN /usr/bin/sqlite3 /etc/keydb/test.db
# Install app dependencies
COPY src/package.json /usr/src/app/
RUN npm install
# For watching files
RUN npm install --global nodemon
# For running tests
RUN npm install --global expect
# Bundle app source
COPY ./src /usr/src/app
# Run tests on build
RUN npm test
EXPOSE 8080
# Run tests and restart server on file changes
CMD [ "nodemon", "-x", "npm test", "|", "nodemon", "-L", "server.js" ]
