grandnode / grandnode2

Open-Source eCommerce Platform on .NET Core, MongoDB, AWS DocumentDB, Azure CosmosDB, LiteDB & Vue.js
https://grandnode.com/
GNU General Public License v3.0
1.05k stars 431 forks source link

Optimize Dockerfile #480

Open ghorbani-ali opened 4 months ago

ghorbani-ali commented 4 months ago

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 commented 4 months ago

@ghorbani-ali please merge from main branch

ghorbani-ali commented 4 months ago

@ghorbani-ali please merge from main branch

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

KrzysztofPajak commented 4 months ago

@ghorbani-ali you have conflicts, please resolve it

ghorbani-ali commented 3 months ago

@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 commented 3 months ago

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

ghorbani-ali commented 3 months ago

@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?

ghorbani-ali commented 3 months ago

@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.