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

Reduce Docker image size #269

Closed
ngosang opened this issue Aug 24, 2021 · 4 comments
Closed

Reduce Docker image size #269

ngosang opened this issue Aug 24, 2021 · 4 comments

Comments

@ngosang
Copy link
Contributor

ngosang commented Aug 24, 2021

Wallabag Docker image size uncompressed is 574 MB
According to dive the image can be reduced at least in 100 MB.

I have some ideas but I'm not expert in php/composer:

  • Why do you install Python and Python libraries? It takes ~188MB
  • Remove /root/composer/ I think this is the composer cache ~43 MB
  • Remove .git folder (repository history) in the final image. I think it will be wise to remove all but the php source code and config.
  • Is it possible to uninstall composer and other dependencies after the installation is complete? (I think you only need php, php-libs and nginx)
  • Vendor folder is ~104MB. Are all dependencies required?

Update: If you don't agree, another alternative is to publish 2 images (with different tags). I think the slim image could be 1/3 the size of the current image with the same features (redis). Some of us are running Wallabag in RaspberryPi with low resources. :)

@Kdecherf
Copy link
Member

Hello @ngosang,

You should definitely take a look at #256 :)

@ngosang
Copy link
Contributor Author

ngosang commented Aug 24, 2021

Thank you, I will.
Just for reference. This app uses same technologies Php+Mysql and the image is just 50MB uncompressed / 20MB compressed:
https://hub.docker.com/r/kanboard/kanboard/
https://github.com/kanboard/kanboard/blob/master/Dockerfile

@Kdecherf
Copy link
Member

Well it's not relevant to compare these two projects as they don't have the same amount of dependencies nor features.

ngosang added a commit to ngosang/docker that referenced this issue Aug 29, 2021
Size (uncompressed): Previous 573.1 MB  /  This PR 225.8 MB
Container startup time is faster. Ansible was slow
Build time is 3 times faster. Less packages and TAR download
No changes required by the user. Same env vars, same paths, same core packages ...

* Update Alpine 3.14. gnu-libiconv is already fixed in this version
* Remove heavy packages: ansible, git, make, bash ...
* Download Wallabag TAR. Is faster and git is not required
* Replace environment variables with envsubst
* Reorder steps to build faster and reduce image size
ngosang added a commit to ngosang/docker that referenced this issue Aug 29, 2021
Size (uncompressed): Previous 573.1 MB  /  This PR 225.8 MB
Container startup time is faster. Ansible was slow
Build time is 3 times faster. Less packages and TAR download
No changes required by the user. Same env vars, same paths, same core packages ...

* Update Alpine 3.14. gnu-libiconv is already fixed in this version
* Remove heavy packages: ansible, git, make, bash ...
* Download Wallabag TAR. Is faster and git is not required
* Replace environment variables with envsubst
* Reorder steps to build faster and reduce image size
ngosang added a commit to ngosang/docker that referenced this issue Aug 29, 2021
Size (uncompressed): Previous 573.1 MB  /  This PR 225.8 MB
Container startup time is faster. Ansible and chown where slow
Build time is 3 times faster. Less packages and TAR download
No changes required by the user. Same env vars, same paths, same core packages ...

* Update Alpine 3.14. gnu-libiconv is already fixed in this version
* Remove heavy packages: ansible, git, make, bash ...
* Download Wallabag TAR. Is faster and git is not required
* Replace environment variables with envsubst
* Reorder steps to build faster and reduce image size
ngosang added a commit to ngosang/docker that referenced this issue Aug 29, 2021
Size (uncompressed): Previous 573.1 MB  /  This PR 225.8 MB
Container startup time is faster. Ansible and chown where slow
Build time is 3 times faster. Less packages and TAR download
No changes required by the user. Same env vars, same paths, same core packages ...

* Update Alpine 3.14. gnu-libiconv is already fixed in this version
* Remove heavy packages: ansible, git, make, bash ...
* Download Wallabag TAR. Is faster and git is not required
* Replace environment variables with envsubst
* Reorder steps to build faster and reduce image size
ngosang added a commit to ngosang/docker that referenced this issue Aug 29, 2021
Size (uncompressed): Previous 573.1 MB  /  This PR 225.8 MB
Container startup time is faster. Ansible and chown where slow
Build time is 3 times faster. Less packages and TAR download
No changes required by the user. Same env vars, same paths, same core packages ...

* Update Alpine 3.14. gnu-libiconv is already fixed in this version
* Remove heavy packages: ansible, git, make, bash ...
* Download Wallabag TAR. Is faster and git is not required
* Replace environment variables with envsubst
* Reorder steps to build faster and reduce image size
ngosang added a commit to ngosang/docker that referenced this issue Aug 29, 2021
Size (uncompressed): Previous 573.1 MB  /  This PR 225.8 MB
Container startup time is faster. Ansible and chown where slow
Build time is 3 times faster. Less packages and TAR download
No changes required by the user. Same env vars, same paths, same core packages ...

* Update Alpine 3.14. gnu-libiconv is already fixed in this version
* Remove heavy packages: ansible, git, make, bash ...
* Download Wallabag TAR. Is faster and git is not required
* Replace environment variables with envsubst
* Reorder steps to build faster and reduce image size
martin-v pushed a commit to martin-v/wallabag-docker that referenced this issue Feb 11, 2022
Size (uncompressed): Previous 573.1 MB  /  This PR 225.8 MB
Container startup time is faster. Ansible and chown where slow
Build time is 3 times faster. Less packages and TAR download
No changes required by the user. Same env vars, same paths, same core packages ...

* Update Alpine 3.14. gnu-libiconv is already fixed in this version
* Remove heavy packages: ansible, git, make, bash ...
* Download Wallabag TAR. Is faster and git is not required
* Replace environment variables with envsubst
* Reorder steps to build faster and reduce image size
ngosang added a commit to ngosang/docker that referenced this issue Jul 27, 2022
Size (uncompressed): Previous 573.1 MB  /  This PR 225.8 MB
Container startup time is faster. Ansible and chown where slow
Build time is 3 times faster. Less packages and TAR download
No changes required by the user. Same env vars, same paths, same core packages ...

* Update Alpine 3.14. gnu-libiconv is already fixed in this version
* Remove heavy packages: ansible, git, make, bash ...
* Download Wallabag TAR. Is faster and git is not required
* Replace environment variables with envsubst
* Reorder steps to build faster and reduce image size
@ngosang
Copy link
Contributor Author

ngosang commented Oct 29, 2022

Fixed in the linked PRs.

@ngosang ngosang closed this as completed Oct 29, 2022
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

No branches or pull requests

2 participants