Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker support #22

Merged
merged 2 commits into from Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/Dockerfile
@@ -0,0 +1,14 @@
FROM node:lts

WORKDIR /app

# Install all dependencies.
COPY package.json ./
COPY package-lock.json ./
RUN npm install

COPY public/ ./
COPY server.js ./

EXPOSE 3000
ENTRYPOINT ["npm", "run", "start"]
15 changes: 15 additions & 0 deletions app/docker-compose.yml
@@ -0,0 +1,15 @@
version: "3.6"
services:
webserver:
build:
context: ./
ports:
- 3000:3000
environment:
MONGO_URL: "mongodb://mongodb/mirrordb"
mongodb:
image: mongo:latest
volumes:
- mongoData:/data/db
volumes:
mongoData:
4 changes: 2 additions & 2 deletions app/server.js
Expand Up @@ -2,7 +2,7 @@ const express = require("express");
const mongoose = require("mongoose");

//url param indicates machine mongodb is running on /nameOfDatabase
mongoose.connect("mongodb://localhost/mirrordb");
mongoose.connect(process.env.MONGO_URL || "mongodb://localhost/mirrordb");


// https://learn.zybooks.com/zybook/UMASSCOMPSCI326RichardsAcademicYear2020/chapter/11/section/8
Expand Down Expand Up @@ -33,4 +33,4 @@ app.get("/create", (req,res) => {

//serve static files from public dir
app.use(express.static("public"));
app.listen(3000);
app.listen(3000);