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

feat(docker): review ownership and permission #219

Closed
iromli opened this issue May 9, 2022 · 6 comments · Fixed by #229
Closed

feat(docker): review ownership and permission #219

iromli opened this issue May 9, 2022 · 6 comments · Fixed by #229
Assignees

Comments

@iromli
Copy link
Contributor

iromli commented May 9, 2022

Problems

Current images adjust ownership and permission for several directories and files for non-root user. The issue is some of the commands are using chown, for example:

RUN chown -R 1000:1000 /opt/jans/jetty

Unfortunately, due to docker build limitation, the chown command will create extra layer and add the size as huge as the chown-ed directory/file size.

Build using chown command

For illustration, inspecting image layers using docker images will show the SIZE:

» docker images | grep casa
REPOSITORY                               TAG           IMAGE ID       CREATED          SIZE
gluufederation/casa                      5.0.0_dev     2c34c75df662   9 days ago      600MB

By using docker history command, we know that adjusting ownership and permission via chown increased the size of the image (approx. 130MB), as seen below:

» docker history gluufederation/casa:5.0.0_dev                                                                                                        
IMAGE          CREATED       CREATED BY                                      SIZE      COMMENT                                                                                                
<missing>      9 days ago    RUN |7 JETTY_VERSION=11.0.8 JETTY_HOME=/opt/…   130MB     buildkit.dockerfile.v0        

Build without using chown command

Temporarily commenting out chown command produces smaller image size:

» docker images | grep casa
REPOSITORY                               TAG           IMAGE ID       CREATED          SIZE
gluufederation/casa                      5.0.0_dev     0cba09ff0291   9 days ago      470MB

Now the history shows small size while adjusting permission:

» docker history janssenproject/casa:5.0.0_dev                                                                                                  
IMAGE          CREATED         CREATED BY                                      SIZE      COMMENT                                                      
<missing>      9 days ago    RUN |7 JETTY_VERSION=11.0.8 JETTY_HOME=/opt/…   4.66kB    buildkit.dockerfile.v0                             

Goals

  • Review the usage of chown or similar command that changes ownership and permission of directories and files
  • If chown is inevitable, only adjust specific directories and files (i.e. chown /opt/jans/jetty/casa/logs instead of /opt/jans/jetty/casa; the latter contain webapps/casa.war which is a huge file)
  • Re-test to avoid regression
@iromli iromli self-assigned this May 9, 2022
@iromli
Copy link
Contributor Author

iromli commented May 9, 2022

@moabu While testing the implementation on janssenproject/casa:5.0.0_dev image, i found out that to unlock admin feature, the .administrable file must be placed inside jetty/casa directory. Unfortunately running chown -R jetty/casa or chmod -R g=u jetty/casa will still increase the image (approx. 113MB) due to extra layer created by docker build.

@jgomer2001 is it possible to override the location of this .administrable file, i.e. $HOME/.administrable?

@jgomer2001
Copy link
Contributor

sure! can you open an issue?

@moabu
Copy link
Member

moabu commented May 11, 2022

Yep customizing the location should help with that.

@jgomer2001
Copy link
Contributor

@iromli you have to pass -Dadmin.lock=/path/to/file from now on

@iromli
Copy link
Contributor Author

iromli commented May 12, 2022

@jgomer2001 thanks, i will try it

@iromli
Copy link
Contributor Author

iromli commented May 12, 2022

@jgomer2001 custom admin lock file works! thanks

moabu pushed a commit that referenced this issue May 16, 2022
…229)

* feat: adjust ownership and permission to avoid bloated images (#219)

* fix: env var name for admin lock file

* docs: add missing env var for admin lock file
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 a pull request may close this issue.

3 participants