-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from windymelt/plastic-user-group
Dockerで実行時、アーティファクト生成時のownerをホスト環境のものに揃える
- Loading branch information
Showing
2 changed files
with
84 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
# Script to adopt uid/gid to host's. | ||
# See https://zenn.dev/anyakichi/articles/73765814e57cba | ||
|
||
# Running as root here... | ||
|
||
export USER=zundamon | ||
export HOME=/home/zundamon | ||
|
||
uid=$(stat -c "%u" .) | ||
gid=$(stat -c "%g" .) | ||
|
||
if [ "$uid" -ne 0 ]; then | ||
if [ "$(id -g $USER)" -ne $gid ]; then | ||
# gid of $HOME should be host's | ||
getent group $gid >/dev/null 2>&1 || groupmod -g $gid $USER | ||
chgrp -R $gid $HOME | ||
fi | ||
if [ "$(id -u $USER)" -ne $uid ]; then | ||
# uid of $HOME should be host's | ||
usermod -u $uid $USER | ||
fi | ||
fi | ||
|
||
# setpriv is a minimal tool like sudo/doas. | ||
# Masquerade to host's user | ||
# Coretto's setpriv does not have --init-groups option. we use --clear-groups. | ||
# Binaries will be deployed into /opt/docker by sbt-native-packager. | ||
exec setpriv --reuid=$USER --regid=$USER --clear-groups /opt/docker/bin/zmm "$@" |