Skip to content

Update Dockerfile to a functional multistage build#389

Open
danfmsouza wants to merge 3 commits into
ThaumRystra:developfrom
danfmsouza:docker-build
Open

Update Dockerfile to a functional multistage build#389
danfmsouza wants to merge 3 commits into
ThaumRystra:developfrom
danfmsouza:docker-build

Conversation

@danfmsouza
Copy link
Copy Markdown

🚀 Dockerfile Optimization: Key Changes and Improvements

The latest updates to the Dockerfile introduced several significant enhancements. Below is a breakdown of the key changes and their benefits.


🌍 Global Variables (ARG)

  • Centralized important configurations at the top of the file.
  • Improved version control for Node.js and Meteor.
  • Standardized directory structure for better organization and maintainability.

Build Optimization

  • Switched to node:14-slim as the base image to reduce image size.
  • Improved layer organization to optimize Docker's caching mechanism.
  • More efficient removal of unnecessary files to keep the final image lightweight.

🔒 Security Enhancements

  • Consistent use of a non-root user (mt) for improved security.
  • Minimal installation of dependencies to reduce attack surface.
  • Removed sensitive and temporary files to avoid unnecessary exposure.

🏗️ Code Structure Improvements

Dockerfile Enhancements

  • Used npm ci --omit=dev for faster and cleaner dependency installations.
  • Optimized the final bundle by removing unnecessary files.
  • Improved npm cache management to avoid excessive storage usage.
  • Clear separation between build and runtime stages for better maintainability.
  • Switched to Alpine Linux in the runtime stage for a smaller footprint.

⚙️ Runtime Environment Improvements

  • Cleaner Meteor environment configuration for improved stability.
  • Better management of environment variables to avoid conflicts.
  • Proper exposure of port 3000 for service accessibility.
  • Used CMD instead of ENTRYPOINT for greater flexibility when running the container.

These optimizations make the Docker image lighter, more efficient, and more secure, ensuring faster builds and a better deployment experience. 🚀

Comment thread Dockerfile Outdated
Comment thread app/package.json
@ExtraTNT
Copy link
Copy Markdown

ExtraTNT commented Aug 8, 2025

should also fix gateway issues, at least for me i had them before going for Entrypoint with []... took me way too long

@danfmsouza
Copy link
Copy Markdown
Author

should also fix gateway issues, at least for me i had them before going for Entrypoint with []... took me way too long

Thanks! I’ll check it out. I made those changes just to simplify deployment in a test pipeline I was using, so yeah, it probably needs some tweaks to be in good shape. I’ll also build on what @ShinySaana Saana did in another PR and clean this up here too!

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.

3 participants