Skip to content

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

Closed
Aditya-269 wants to merge 1 commit intosugarlabs:masterfrom
Aditya-269:docker-migrate-to-node-base
Closed

Migrate Dockerfile to Node.js Base Image for Proper Application Deployment#4662
Aditya-269 wants to merge 1 commit intosugarlabs:masterfrom
Aditya-269:docker-migrate-to-node-base

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

@github-actions
Copy link
Contributor

✅ 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

@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2025

This pull request has been open for more than 60 days without any activity. It will be closed in 3 days unless the stale label is removed or commented on.

@github-actions github-actions bot added the Stale label Jul 5, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2025

Closed pull request due to inactivity for more than 63 days.

@github-actions github-actions bot closed this Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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