-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebc3c3f
commit 669128e
Showing
26 changed files
with
1,265 additions
and
1,237 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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
PORT=3000 | ||
PORT=5513 | ||
MONGODB_URI=mongodb+srv://swarnendumaity633:[email protected] | ||
# CORS_ORIGIN=* | ||
# ACCESS_TOKEN_SECRET=chai-aur-code | ||
# ACCESS_TOKEN_EXPIRY=1d | ||
# REFRESH_TOKEN_SECRET=chai-aur-backend | ||
# REFRESH_TOKEN_EXPIRY=10d | ||
CORS_ORIGIN=* | ||
|
||
# PRODUCT_PER_PAGE= 8 | ||
REDIS_URI = redis://:123@localhost:6379 | ||
PRODUCT_PER_PAGE= 8 | ||
|
||
# CLOUDINARY_CLOUD_NAME= | ||
# CLOUDINARY_API_KEY= | ||
# CLOUDINARY_API_SECRET= | ||
STRIPE_KEY=sk_test_51PaUaI2MF7toLiOy7fEqmDVyn5gQGLw74VjM4JVYYLhHliC3URzxU7wDDpNaNvb2FyXQYuykqRIwcqi0udTjs0iP00Dg7iC10i | ||
|
||
CLOUDINARY_CLOUD_NAME=dtffsa7p9 | ||
CLOUDINARY_API_KEY=627319636958367 | ||
CLOUDINARY_API_SECRET=JJDCWE-z5TjdX2KBBUMnMyrCzo8 |
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,29 +1,42 @@ | ||
# Use the official Node.js image as the base image | ||
FROM node:20-alpine | ||
FROM node:20-alpine as builder | ||
|
||
# Create and set the working directory | ||
WORKDIR /usr/src/app | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json to the working directory | ||
COPY package*.json ./ | ||
|
||
# Install dependencies | ||
RUN npm install | ||
RUN npm ci | ||
|
||
# Copy the rest of the application code to the working directory | ||
COPY . . | ||
|
||
# Install TypeScript globally | ||
RUN npm install -g typescript | ||
|
||
# Build the TypeScript code | ||
RUN npm run build | ||
|
||
# Check if the dist directory and index.js file exist | ||
RUN ls -la dist | ||
#This will make the size of the container so big because of dev dependencies and all | ||
#Thats why I am going to use multistage system of Docker | ||
|
||
# build production image | ||
|
||
FROM node:18-alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY package*.json ./ | ||
|
||
#Env is in production, | ||
ENV NODE_ENV=production | ||
|
||
RUN npm ci | ||
|
||
COPY --from=builder /app/dist ./dist | ||
|
||
#Changing the ownership from root to Node | ||
RUN chown -R node:node /app && chmod -R 755 /app | ||
|
||
RUN npm install pm2 -g | ||
|
||
COPY ecosystem.config.js . | ||
|
||
USER node | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 3000 | ||
EXPOSE 5513 | ||
|
||
# Command to run the app | ||
CMD ["npm", "run", "dev"] | ||
CMD ["pm2-runtime", "dev ", "ecosystem.config.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
version: '3.8' | ||
|
||
services: | ||
redis: | ||
image: redis:latest | ||
container_name: ecom-redis | ||
ports: | ||
- "6379:6379" | ||
environment: | ||
- REDIS_PASSWORD= 123 | ||
volumes: | ||
- redis-data:/data/cache | ||
networks: | ||
- ecom-network | ||
command: redis-server --requirepass myredispassword | ||
|
||
backendapi: | ||
image: swarnendu19/ecommerce-app:v1 | ||
container_name: ecommerce-app | ||
ports: | ||
-'5513:5513' | ||
networks: | ||
- ecom-network | ||
env_file: | ||
- .env | ||
depends_on: | ||
- redis | ||
|
||
networks: | ||
ecom-network: | ||
driver: bridge |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
apps: [ | ||
{ | ||
name: "ecommerce-app", | ||
script: "./dist/index.js", | ||
instances: "max", | ||
exec_mode: "cluster", | ||
env: { | ||
NODE_ENV: "development", | ||
}, | ||
env_production: { | ||
NODE_ENV: "production", | ||
}, | ||
}, | ||
], | ||
}; |
Oops, something went wrong.