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 container configurations #141

Merged
merged 7 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.git
.github
21 changes: 21 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:latest

ENV NODE_ENV="development"

# Copy package.json file into container
COPY package.json package.json
COPY package-lock.json package-lock.json

# Install node modules
RUN npm install && \
npm install --only=dev && \
npm cache clean --force --loglevel=error

# Volume to mount source code into container
VOLUME [ "/server" ]

# move to the source code directory
WORKDIR /server

# Start the server
CMD mv ../node_modules . && npm run dev
kmehant marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 14 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:latest

ENV NODE_ENV="production"

WORKDIR /server

RUN git clone https://github.com/codeuino/social-platform-donut-backend.git

WORKDIR /server/social-platform-donut-backend

RUN npm install && npm cache clean --force --loglevel=error

# Start the server
CMD [ "npm", "start" ]
27 changes: 27 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3"
services:
server:
container_name: server
restart: always
expose:
- "5000"
build:
context: .
dockerfile: Dockerfile.dev
volumes:
- ./:/server
ports:
- "5000:5000"
links:
- mongo
env_file:
- .env.dev
mongo:
container_name: mongo
image: mongo
volumes:
- db-data:/data/db
ports:
- "27017:27017"
volumes:
db-data:
30 changes: 30 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "3"
services:
server:
container_name: server-prod
restart: always
expose:
- "5000"
build:
context: .
dockerfile: Dockerfile.prod
ports:
- "5000:5000"
links:
- mongo
environment:
- PORT=5000
- NODE_ENV="production"
- JWT_SECRET="thisismysupersecrettokenjustkidding"
- DATABASE_URL="mongodb://mongo:27017/donut-development"
- SENDGRID_API_KEY='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'
- SOCKET_PORT=8810
mongo:
container_name: mongo
image: mongo
volumes:
- db-data:/data/db
ports:
- "27017:27017"
volumes:
db-data: