This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "docker-nodes", | |
| "version": "1.0.0", | |
| "description": "for medium purpose", | |
| "main": "index.js", | |
| "dependencies": { | |
| "dotenv": "^8.2.0", | |
| "express": "^4.17.1", | |
| "mongoose": "^5.7.11" | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| APP_PORT=9000 | |
| MONGOURI="mongodb://mongo:27017/doggy" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const mongoose = require("mongoose"); | |
| mongoose.connect(process.env.MONGOURI, { useNewUrlParser: true }); | |
| const dog = mongoose.model("Dog", { | |
| name: String, | |
| age: Number, | |
| gender: String, | |
| }); | |
| module.exports = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require("dotenv").config(); | |
| const express = require("express"); | |
| const bodyParser = require("body-parser"); | |
| const app = express(); | |
| const port = process.env.APP_PORT || 3005; | |
| const { dog } = require("./mongo"); | |
| app.use(bodyParser.json()); | |
| app.use(bodyParser.urlencoded({ extended: true })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM node:alpine | |
| RUN apk update && apk add ca-certificates openssl && update-ca-certificates | |
| RUN mkdir /app | |
| ADD . /app | |
| WORKDIR /app | |
| RUN npm install | |
| CMD npm start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: "3.7" | |
| services: | |
| mongo: | |
| image: mongo:latest | |
| container_name: mongoDB | |
| hostname: mongo | |
| volumes: | |
| - mongo:/data/db | |
| restart: always | |
| networks: |