diff --git a/.github/workflows/checkbuild.yml b/.github/workflows/checkbuild.yml index fe6e4ce..5fcfb92 100644 --- a/.github/workflows/checkbuild.yml +++ b/.github/workflows/checkbuild.yml @@ -1,4 +1,4 @@ -name: Docker Build +name: Docker Build with pnpm on: push: @@ -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 diff --git a/dockerfile b/dockerfile index 9ef0b20..60cfaeb 100644 --- a/dockerfile +++ b/dockerfile @@ -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"]