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

chore(dockerfile): use alpine images to reduce the size of Docker images #1298

Merged
merged 2 commits into from
May 18, 2023

Conversation

wivwiv
Copy link
Member

@wivwiv wivwiv commented May 18, 2023

PR Checklist

If you have any questions, you can refer to the Contributing Guide

What is the current behavior?

Please describe the current behavior and link to a relevant issue.

Issue Number

Example: #123

What is the new behavior?

Please describe the new behavior or provide screenshots.

Use the alpine image, a lighter base image to build the MQTTX CLI Docker, and be able to reduce the size by 600MB.

image

In the future we could consider putting the pkg compiled binary package into an alpine image that does not contain the nodejs runtime.
The image would then be only 60MB in size.
The reason for not implementing this now is that it requires a more complex build step

Does this PR introduce a breaking change?

  • Yes
  • No

Specific Instructions

Are there any specific instructions or things that should be known prior to review?

Other information

@@ -1,4 +1,4 @@
FROM node:16
FROM node:16-alpine

WORKDIR /app
COPY . ./

Choose a reason for hiding this comment

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

with the code patch review:

  1. The first line changes the base image from "node:16" to "node:16-alpine". This is a good change as it will reduce the size of the container image and help the application run faster.

  2. The second line sets the working directory to "/app", which is a good practice.

  3. The third line copies all the files from the current folder to the "/app" directory. This is also a good practice, as it ensures that all the necessary files are available for the application.

Overall, the code patch looks good and should work as expected.

@wivwiv wivwiv added the dependencies Pull requests that update a dependency file label May 18, 2023
@Red-Asuka Red-Asuka merged commit ce7cd24 into main May 18, 2023
@Red-Asuka Red-Asuka deleted the 0518_docker_thinning branch May 18, 2023 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants