-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from arnab2001/Dockerize
Docker
- Loading branch information
Showing
7 changed files
with
63 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,6 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
readme.md | ||
|
||
/data | ||
# assets folder | ||
/server/public/assets |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
# production | ||
/build | ||
|
||
/package-lock.json | ||
# misc | ||
.DS_Store | ||
.env.local | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
# Use a base image with Nginx pre-installed | ||
FROM nginx:alpine | ||
# Build react client | ||
FROM node:16-alpine | ||
|
||
# Copy the built frontend files to the appropriate location in the container | ||
COPY build/ /usr/share/nginx/html | ||
# Working directory be app | ||
WORKDIR /usr/src/app | ||
|
||
# Expose the port your frontend application listens on | ||
EXPOSE 80 | ||
COPY package*.json ./ | ||
|
||
# Set the startup command to run the Nginx server | ||
CMD ["nginx", "-g", "daemon off;"] | ||
### Installing dependencies | ||
|
||
RUN npm install --silent | ||
|
||
# copy local files to app folder | ||
COPY . . | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["npm","start"] | ||
|
||
# docker build -t arnabchat2001/client . | ||
# docker tag arnabchat2001/client arnabchat2001/client:v2 | ||
# docker run -p 3000:3000 arnabchat2001/client:v2 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,30 @@ | ||
version: "3" | ||
version: '3' | ||
|
||
services: | ||
backend: | ||
image: backend-image | ||
client: | ||
build: | ||
context: ./client | ||
dockerfile: Dockerfile | ||
ports: | ||
- "3000:3000" | ||
depends_on: | ||
- server | ||
|
||
server: | ||
build: | ||
context: ./server | ||
dockerfile: Dockerfile | ||
ports: | ||
- "3001:3001" | ||
environment: | ||
- MONGO_URL='mongodb+srv://arnab0321:bH1Ttke9EZBmYClg@cluster0.dehf4yw.mongodb.net/?retryWrites=true&w=majority' | ||
# Add any additional configuration or volumes as needed | ||
MONGO_URL: "mongodb+srv://arnab0321:bH1Ttke9EZBmYClg@cluster0.dehf4yw.mongodb.net/?retryWrites=true&w=majority" | ||
depends_on: | ||
- mongo | ||
|
||
frontend: | ||
image: frontend-image | ||
build: | ||
context: ./client | ||
mongo: | ||
image: mongo | ||
ports: | ||
- "80:80" | ||
- "27017:27017" | ||
volumes: | ||
- ./data:/data/db # You can adjust the volume mount based on your preferences | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
FROM node:18.3.0-alpine3.14 | ||
FROM node:16.13.0 | ||
|
||
# Set the working directory inside the container | ||
WORKDIR /app | ||
# Create App Directory | ||
RUN mkdir -p /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
# Copy package.json and package-lock.json to the container | ||
# Install Dependencies | ||
COPY package*.json ./ | ||
|
||
# Install dependencies | ||
RUN npm install --f | ||
RUN npm install --silent | ||
|
||
# Copy the rest of the backend files to the container | ||
# Copy app source code | ||
COPY . . | ||
|
||
# Expose the port your backend server listens on | ||
# Exports | ||
EXPOSE 3001 | ||
|
||
# Set the startup command to run your backend server | ||
CMD ["npm", "start"] | ||
CMD ["node","index.js"] |
This file contains 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