Skip to content

Commit

Permalink
feat : changed dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
surajhub255 committed Oct 25, 2024
1 parent 6aeb722 commit 13df11c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
18 changes: 5 additions & 13 deletions .github/workflows/checkbuild.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Build
name: Docker Build with pnpm

on:
push:
Expand All @@ -21,23 +21,15 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Step 3: Log in to Docker Hub (Optional, if you need to push the image to Docker Hub)
# Uncomment and replace DOCKER_USERNAME and DOCKER_PASSWORD in Secrets if needed
# - name: Log in to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

# Step 4: Build the Docker image
- name: Build Docker image
# Step 3: Build the Docker image
- name: Build Docker image with pnpm
run: docker build -t my-nextjs-app .

# Step 5: (Optional) Run Docker container for testing
# Step 4: (Optional) Run Docker container for testing
- name: Run Docker container
run: docker run -d -p 3000:3000 --name my-nextjs-app my-nextjs-app

# Step 6: Verify the container is running (Optional)
# Step 5: Verify the container is running (Optional)
- name: Test if container is running
run: |
sleep 5 # Wait for the container to start
Expand Down
26 changes: 14 additions & 12 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
# Step 1: Use the official Node.js image as the base image
FROM node:18-alpine

# Step 2: Set the working directory inside the container
# Step 2: Install pnpm globally
RUN npm install -g pnpm

# Step 3: Set the working directory inside the container
WORKDIR /app

# Step 3: Copy the package.json and package-lock.json files to the container
COPY package.json package-lock.json ./
# Step 4: Copy the package.json and pnpm-lock.yaml files to the container
COPY package.json pnpm-lock.yaml ./

# Step 4: Install the dependencies
RUN npm install
# Step 5: Install the dependencies using pnpm
RUN pnpm install

# Step 5: Copy the rest of the application code to the container
# This includes all files and directories needed to build and run the Next.js app
# Step 6: Copy the rest of the application code to the container
COPY . .

# Step 6: Build the Next.js application
RUN npm run build
# Step 7: Build the Next.js application
RUN pnpm run build

# Step 7: Expose the port the app runs on
# Step 8: Expose the port the app runs on
EXPOSE 3000

# Step 8: Define the command to run the application
CMD ["npm", "run", "start"]
# Step 9: Define the command to run the application using pnpm
CMD ["pnpm", "run", "start"]

0 comments on commit 13df11c

Please sign in to comment.