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 container updated #67

Closed
wants to merge 2 commits into from
Closed

Docker container updated #67

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 avoid running containers as root for security.

These are the improvements you should make:

  • Use multi-stage builds in Dockerfile to optimize image size and security.
  • Avoid running as root in Dockerfile: Add a non-root user and switch to it with the USER instruction.

Use multi-stage builds in Dockerfile to optimize image size and security.

You are currently using a single-stage build in your Dockerfile. Implementing multi-stage builds will help reduce the final image size and improve security by only including necessary files in the runtime image. Here’s how you can modify your Dockerfile:

# Builder stage
FROM node:14-alpine AS builder
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .

# Runtime stage
FROM node:14-alpine
WORKDIR /usr/src/app
COPY --from=builder /usr/src/app/dist ./dist
ENV PORT 8080
EXPOSE 8080
CMD ["npm", "start", "--no-update-notifier"]

Avoid running as root in Dockerfile: Add a non-root user and switch to it with the USER instruction.

Running containers as the root user poses security risks. You should create a non-root user and switch to it before running your application. Here’s how to implement this in your Dockerfile:

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

This ensures that your application runs with limited privileges, enhancing security.

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