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

Added dockerfile docker-compose.yml #266

Merged
merged 3 commits into from
Oct 12, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Step 1: Use an official Nginx image from Docker Hub
FROM nginx:alpine

# Step 2: Copy your local files (frontend) to the Nginx html folder
COPY . /usr/share/nginx/html

# Step 3: Start Nginx server
CMD ["nginx", "-g", "daemon off;"]
18 changes: 18 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Step 1: Use an official Node.js image from Docker Hub
FROM node:14-alpine

# Step 2: Set working directory in container
WORKDIR /usr/src/app

# Step 3: Copy package.json and install dependencies
COPY backend/package*.json ./
RUN npm install

# Step 4: Copy the backend code to the container
COPY backend/ .

# Step 5: Expose the backend's port (if your backend runs on port 3000, adjust as needed)
EXPOSE 3000

# Step 6: Start the backend server
CMD ["npm", "start"]
41 changes: 41 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
services:
frontend:
build:
context: .
dockerfile: Dockerfile
ports:
- "80:80"
depends_on:
- backend
networks:
- app-network

backend:
build:
context: .
dockerfile: backend/Dockerfile
ports:
- "3000:3000"
networks:
- app-network
environment:
- NODE_ENV=production
- MONGODB_URI=mongodb://mongo:27017/mydatabase
depends_on:
- mongo

mongo:
image: mongo:latest
ports:
- "27017:27017"
volumes:
- mongo_data:/data/db
networks:
- app-network

networks:
app-network:
driver: bridge

volumes:
mongo_data: