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

Demo - [Failed Pipeline] - Added dockerfile bug #97

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wvl94
Copy link
Contributor

@wvl94 wvl94 commented Nov 5, 2024

💡 PR Summary generated by FirstMate

Overview: Added a Dockerfile to streamline the application build process.

Changes:
New Dockerfile:

  • Created /Dockerfile for building the Node.js application.
  • Utilizes multi-stage builds to optimize image size.
  • Installs dependencies and sets up the application to run on port 8080.

TLDR: A new Dockerfile has been added to facilitate the build process; please review the multi-stage build setup.

Generated by FirstMate and automatically updated on every commit.

Copy link

firstmatebot bot commented Nov 5, 2024

PR Review

⚠️ It seems that you can still improve the quality of your PR:

    ❌ Docker & containerization: Dockerfile must specify a non-root user to enhance security and limit privileges.

Generated by Firstmate to make sure you can focus on coding new features.

Comment on lines +7 to +11
FROM node:18-alpine
WORKDIR /app
COPY --from=build /node_modules ./node_modules
EXPOSE 8080
CMD ["npm", "start", "--no-update-notifier"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alt text

The Dockerfile does not specify a non-root user, which can pose security risks. You should add a non-root user to enhance security by including the following lines:

RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser

This ensures the application runs with limited privileges.

Copy link

firstmatebot bot commented Nov 5, 2024

alt text

I analysed the failed pipeline job Validate docker:

Failure Analysis

The pipeline crashed during the docker build step due to a failure in the Dockerfile at line 9, where it attempts to copy the node_modules directory from the build stage. The error message indicates that the /node_modules directory was not found:

ERROR: failed to calculate checksum of ref ...: "/node_modules": not found

This suggests that the npm install command did not successfully create the node_modules directory in the build stage. This could be due to:

  • Missing or incorrect dependencies in package.json.
  • Errors during the npm install process that were not captured in the logs provided.

Suggested Fix

To resolve this issue, ensure that the npm install command runs successfully and creates the node_modules directory. You can modify the Dockerfile to check for errors during the installation:

4 + RUN npm install || { echo 'npm install failed'; exit 1; }

This change will provide a clearer error message if npm install fails, helping to diagnose the underlying issue. Additionally, verify the contents of package.json to ensure all dependencies are correctly defined.

@firstmatecloud firstmatecloud deleted a comment from firstmatebot bot Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant