sbt / sbt-native-packager

sbt Native Packager
https://sbt-native-packager.readthedocs.io/en/stable/
BSD 2-Clause "Simplified" License
1.59k stars 439 forks source link

Allow override chown user and group in copy commands #1399

Open arixmkii opened 3 years ago

arixmkii commented 3 years ago

Would be nice to have an option to use different user and group applied during COPY step. Same effect could be achieved if explicit chown command added, but it will create a new layer.

Why it could be useful. To apply hardening - to make copied files write protected by the user, which will run application (and so that it would not possible to change it by using chmod with the same user).

Currently we apply this via rewriting commands using map/flatMap, which is not really handy.

Proposal - add 2 more settings chownUser and chownGroup both Option[String], and if they are set to Some value, then it will be used and in case of missing value it will fall back to daemonUser and daemonGroup respectively.

We need this applied for multistage docker, but I guess it is better to add the same logic to ChownCopy as well.

I will sketch a PR for this.