Skip to content

Improve Dockerfile with multi-stage build#42

Open
Dustin4444 wants to merge 1 commit into
docker:mainfrom
Dustin4444:improve-dockerfile
Open

Improve Dockerfile with multi-stage build#42
Dustin4444 wants to merge 1 commit into
docker:mainfrom
Dustin4444:improve-dockerfile

Conversation

@Dustin4444

@Dustin4444 Dustin4444 commented Apr 26, 2025

Copy link
Copy Markdown

Update Dockerfile to use a multi-stage build for reducing the final image size and separating build and runtime environments.

  • Stage 1: Build

    • Use alpine:3.14 as the base image.
    • Set environment variables for build.
    • Install nodejs and npm.
    • Copy package.json and install dependencies.
  • Stage 2: Runtime

    • Use alpine:3.14 as the base image.
    • Set environment variables for runtime.
    • Install nodejs.
    • Copy node_modules from the build stage.
    • Copy application files to /app.
    • Set the command to run the application.

For more details, open the Copilot Workspace session.

Update `Dockerfile` to use a multi-stage build for reducing the final image size and separating build and runtime environments.

* **Stage 1: Build**
  - Use `alpine:3.14` as the base image.
  - Set environment variables for build.
  - Install `nodejs` and `npm`.
  - Copy `package.json` and install dependencies.

* **Stage 2: Runtime**
  - Use `alpine:3.14` as the base image.
  - Set environment variables for runtime.
  - Install `nodejs`.
  - Copy `node_modules` from the build stage.
  - Copy application files to `/app`.
  - Set the command to run the application.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/docker/scout-demo-service/tree/main?shareId=XXXX-XXXX-XXXX-XXXX).

@TheJ-Erk400 TheJ-Erk400 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@sashasmith-syber sashasmith-syber left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

...

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