Skip to content

Migrate Dockerfile to Node.js Base Image for Proper Application Deployment #4662

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Aditya-269
Copy link

@Aditya-269 Aditya-269 commented Apr 28, 2025

Description

This pull request updates the Dockerfile to use a Node.js-based image with a multi-stage build setup for Music Blocks.
The goal is to create an optimized production container by separating the build and runtime environments.


Changes Made

  • First Stage (Build Stage):

    • Base image: node:18-slim
    • Set working directory to /app.
    • Installed all dependencies (npm install).
    • Copied source code into container.
    • Ran linting (npm run lint) and testing (npm run test).
  • Second Stage (Production Stage):

    • Base image: node:18-slim (clean and minimal).
    • Created a non-root user (appuser) for better security.
    • Installed only production dependencies (npm install --production).
    • Copied built application from the build stage.
    • Set correct file permissions.
    • Exposed port 3000.
    • Configured the container to start with npm run serve.

image


Related Issue

Closes #4661

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link

✅ All Jest tests passed! This PR is ready to merge.

@Aditya-269
Copy link
Author

please review this pr

@Ubayed-Bin-Sufian
Copy link
Contributor

@MostlyKIGuess Please review.

@MostlyKIGuess
Copy link
Member

I tried building both of them.
image
Even tho it being multi-stage , it comes bigger almost twice than the one that we have right now, so that's something that can improve.

# Second stage: Final stage
FROM python:3.9-slim
# Run linting and tests
RUN npm run lint
Copy link
Member

Choose a reason for hiding this comment

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

we technically don't need this.

@MostlyKIGuess
Copy link
Member

If we can have the same size, it would be nice to have.

@NaitikSuneri
Copy link

✅ Improvements:
Single npm install in build stage and reusing node_modules.

Proper .dockerignore assumed (e.g., excludes node_modules, .git, etc.).

More explicit Node.js version for reproducibility.

Added HEALTHCHECK for container monitoring.

8c87e541-0956-4c8d-8695-ce6a4cd18c23

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.

Dockerfile Optimization: Migrate to Node.js Base Image for Proper Application Deployment
4 participants