From 324309b2e3aa26145ebdcec74bb2a018dece17f7 Mon Sep 17 00:00:00 2001 From: Ratan Gulati Date: Thu, 30 May 2024 12:49:46 +0530 Subject: [PATCH 1/2] added dockerfile --- .dockerignore | 3 +++ Dockerfile | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fbc2b7d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +.env + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fae9d7c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# Step 1: Use an official Node runtime as a parent image +FROM node:latest + +# Step 2: Set the working directory to /app +WORKDIR /app + +# Step 3: Copy package.json and package-lock.json +COPY package*.json ./ + +# Step 4: Install any needed packages specified in package.json +RUN npm install + +# Step 5: Copy the rest of the working directory contents into the container at /app +COPY . . + +# Step 6: Make port 3000 available to the world outside this container +EXPOSE 3030 + +# Step 7 (Removed): No need to define environment variable here since we're passing them at runtime with --env-file + +# Step 8: Run app when the container launches (Assuming 'npm start' serves your built application) +CMD ["npm", "run","dev"] \ No newline at end of file From cb68a33d4db381e8a112678064f89971fc1e789a Mon Sep 17 00:00:00 2001 From: Ratan Gulati Date: Mon, 3 Jun 2024 12:09:52 +0530 Subject: [PATCH 2/2] added docker file and readme Signed-off-by: Ratan Gulati --- Dockerfile | 22 ------------ README.md | 47 ++++++++++++++++++++++++++ .dockerignore => backend/.dockerignore | 3 +- backend/Dockerfile | 13 +++++++ frontend/.dockerignore | 2 ++ frontend/Dockerfile | 15 ++++++++ frontend/vite.config.js | 5 +++ 7 files changed, 83 insertions(+), 24 deletions(-) delete mode 100644 Dockerfile rename .dockerignore => backend/.dockerignore (68%) create mode 100644 backend/Dockerfile create mode 100644 frontend/.dockerignore create mode 100644 frontend/Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index fae9d7c..0000000 --- a/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -# Step 1: Use an official Node runtime as a parent image -FROM node:latest - -# Step 2: Set the working directory to /app -WORKDIR /app - -# Step 3: Copy package.json and package-lock.json -COPY package*.json ./ - -# Step 4: Install any needed packages specified in package.json -RUN npm install - -# Step 5: Copy the rest of the working directory contents into the container at /app -COPY . . - -# Step 6: Make port 3000 available to the world outside this container -EXPOSE 3030 - -# Step 7 (Removed): No need to define environment variable here since we're passing them at runtime with --env-file - -# Step 8: Run app when the container launches (Assuming 'npm start' serves your built application) -CMD ["npm", "run","dev"] \ No newline at end of file diff --git a/README.md b/README.md index a887642..bc9aca6 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,53 @@ Check the design in [Figma](https://www.figma.com/design/WQnt0qRFSdaV3jW5XF8NSc/
## 🛠️ Getting Started + +### With Docker +1. **Clone the repository** + +```sh + git clone https://github.com/Satyam1923/Spring.git +``` + +### For Backend +1. **Navigate to the backend folder** +```sh +cd backend +``` +2. **Build Docker Image** +```sh +docker build -t : . +``` +3. **Run Docker Image** +```sh +docker run -p 3030:3030 : +``` +4. **Access it locally** + +Go to http://localhost:3030/ + + +### For Frontend +1. **Navigate to the frontend folder** + +```sh +cd frontend +``` +2. **Build Docker Image** +```sh +docker build -t : . +``` +3. **Run Docker Image** +```sh +docker run -p 3000:3000 : +``` +4. **Access it locally** + +Go to http://localhost:3000/ + + +### Without Docker + 1. **Clone the repository** ```sh diff --git a/.dockerignore b/backend/.dockerignore similarity index 68% rename from .dockerignore rename to backend/.dockerignore index fbc2b7d..76add87 100644 --- a/.dockerignore +++ b/backend/.dockerignore @@ -1,3 +1,2 @@ node_modules -.env - +dist \ No newline at end of file diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..316906f --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,13 @@ +FROM node:16-alpine + +WORKDIR /app + +COPY package*.json ./ + +RUN npm install + +COPY . . + +EXPOSE 3030 + +CMD ["npm", "start"] \ No newline at end of file diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000..76add87 --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..47248a3 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,15 @@ +FROM node:16-alpine + +WORKDIR /app + +COPY package*.json ./ + +RUN npm install + +COPY . . + +RUN npm run build + +EXPOSE 3000 + +CMD ["npm", "run", "preview"] \ No newline at end of file diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 5bb6d1f..4d0cdf6 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -5,4 +5,9 @@ import react from "@vitejs/plugin-react"; // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], + + preview: { + host: true, + port: 3000 + } });