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

update: Optimize Dockerfile: improve caching, reduce image size, and … #820

Closed
wants to merge 1 commit into from

Conversation

Engcompaulo
Copy link

…enhance security

Caching Optimization:

The order of commands has been adjusted to leverage Docker's caching mechanism, ensuring that dependencies are only reinstalled when package.json or pnpm-lock.yaml changes. Production Image Size Reduction:

The final image has been streamlined by copying only essential files from the build stage, resulting in a smaller and more efficient production image. Security Enhancements:

A non-root user is now utilized in the production environment, reducing potential security vulnerabilities. This change helps ensure that the application runs with the least privilege necessary. Documentation and Clarity:

Comments have been added throughout the Dockerfile for better understanding and maintainability, making it easier for future developers to comprehend the purpose of each command.

Description

Refactor Dockerfile: optimize caching strategy, minimize production image size, and improve security by using a non-root user

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ x] Refactor (improves the code structure without changing external behavior)

Checklist:

  • I've read & comply with the contributing guidelines
  • I have tested my code for new features & regressions on both mobile & desktop devices, using the latest version of major browsers.
  • I have made corresponding changes to the documentation (README.md).
  • I've checked my modifications for any breaking changes, especially in the config.yml file

…enhance security

Caching Optimization:

The order of commands has been adjusted to leverage Docker's caching mechanism, ensuring that dependencies are only reinstalled when package.json or pnpm-lock.yaml changes.
Production Image Size Reduction:

The final image has been streamlined by copying only essential files from the build stage, resulting in a smaller and more efficient production image.
Security Enhancements:

A non-root user is now utilized in the production environment, reducing potential security vulnerabilities. This change helps ensure that the application runs with the least privilege necessary.
Documentation and Clarity:

Comments have been added throughout the Dockerfile for better understanding and maintainability, making it easier for future developers to comprehend the purpose of each command.
@bastienwirtz
Copy link
Owner

@Engcompaulo Thanks for the contribution!

It looks good, however could you update your PR description to match the change? (please don't use chatGPT of similar tool to write it, the result is crap). There is no security improvements (non root user was already there), no new comment, no change regarding the package installation with package.json and more, as the description mention.
There is a bit of docker layer optimisation and mostly esthetics.

Thanks

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.

2 participants