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

Docker file changes #70

Closed
wants to merge 2 commits into from
Closed

Docker file changes #70

wants to merge 2 commits into from

Conversation

wvl94
Copy link
Contributor

@wvl94 wvl94 commented Oct 28, 2024


💡 Summary generated by FirstMate:

  • Dockerfile updated to use Node.js version 14-alpine instead of 19-alpine
  • Environment variable PORT set to 8080
  • WORKDIR set to /usr/src/app

Copy link

firstmatebot bot commented Oct 28, 2024

PR Review

⚠️ It seems that you can still improve the quality of your PR. Have a look into this:

   

❌ Docker & containerization: Optimize Dockerfiles with multi-stage builds and implement a non-root user for enhanced security.

These are the improvements you should make:

  • Use multi-stage builds in Dockerfile for optimized image size and security.
  • Avoid running as root in Dockerfile; add a non-root user for enhanced security.

Use multi-stage builds in Dockerfile for optimized image size and security.

You are currently using a single-stage build, which can lead to larger image sizes and potential security vulnerabilities. Implementing a multi-stage build allows you to separate the build environment from the runtime environment, reducing the final image size and minimizing the attack surface. Here's how you can modify your Dockerfile:

# Stage 1: Build
FROM node:14-alpine AS build
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .

# Stage 2: Run
FROM node:14-alpine
WORKDIR /usr/src/app
COPY --from=build /usr/src/app ./
ENV PORT 8080
EXPOSE 8080
CMD ["npm", "start", "--no-update-notifier"]

Avoid running as root in Dockerfile; add a non-root user for enhanced security.

Running your application as the root user can expose your container to security risks. Adding a non-root user enhances security by limiting permissions. You can create a user and switch to it in your Dockerfile as follows:

# Add this line in the Run stage
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser

To improve your PR. Please make changes to these files:

  • Dockerfile

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

@wvl94 wvl94 closed this Oct 28, 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