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

Optimize Dockerfile #480

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ghorbani-ali
Copy link

@ghorbani-ali ghorbani-ali commented Apr 7, 2024

Type: feature

Issue

We can use alpine base images to have secure and lightweight images.
This Dockerfile has many commands to build modules statically, and this increases image layers unnecessarily.
There is no need to use the restore command explicitly because it runs implicitly when using the build command.

Solution

Replace SDK base image with alpine to lightweight build stage image.
Use dynamic package build for simplicity and decrease docker image layers.
Remove unnecessary restore commands. According to the official documentation, it is mentioned that this command is executed implicitly by the build command.
Remove duplicates in directory creation.

Testing

By running this command, the image builds cleanly without using cache and shows all the debug information about what is happening.
docker build --no-cache --progress=plain -t grandnode2:latest .

@KrzysztofPajak
Copy link
Member

@ghorbani-ali please merge from main branch

@ghorbani-ali
Copy link
Author

@ghorbani-ali please merge from main branch

Hi @KrzysztofPajak
I’m sorry, I don’t understand. Could you tell me more?

@KrzysztofPajak
Copy link
Member

@ghorbani-ali you have conflicts, please resolve it

@ghorbani-ali
Copy link
Author

@ghorbani-ali you have conflicts, please resolve it

Conflicts have been resolved.

During my investigations, I realized that exactly after my changes, similar changes were made, apparently from your team. What was strange to me was that the changes were exactly the same as mine, with a slight difference in the name and type of implementation. Thank you for explaining the reason for this.

@KrzysztofPajak
Copy link
Member

@ghorbani-ali Have you tried running the GrandNode image with 8.0-alpine ?

@ghorbani-ali
Copy link
Author

@ghorbani-ali Have you tried running the GrandNode image with 8.0-alpine ?

Yes. but only in the build stage, not in runtime stage.
Is there any problem?

Change runtime image to alpine
@ghorbani-ali
Copy link
Author

@KrzysztofPajak
After your reply, I tried to test the project with an Alpine runtime image.
There was no problem.
I added a new commit with these changes.

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.

None yet

2 participants