Skip to content
Snippets Groups Projects
Commit 02425e8f authored by Shachar Itzhaky's avatar Shachar Itzhaky
Browse files

[sdk] Tweak SDK Docker image.

When mounting `/home`, gosu may inadvertantly write to the host's
because of `useradd`.
parent 0c970601
No related merge requests found
......@@ -69,12 +69,14 @@ class DockerTool extends Phase {
mounts(cfg) {
var cwd = process.cwd(),
mnt = cwd.match(/[/][^/]+/)[0],
mnt = cwd.match(/^[/][^/]+/)?.[0],
coqlib = cfg.coqlib;
if (!mnt)
console.warn(`[${ME}-sdk] cannot detect working directory root for '${cwd}';\n` +
` this will probably not work.`)
if (mnt.match(/^[/](Users|home)$/))
mnt = cwd.match(/^[/][^/]+[/][^/]+/)?.[0] ?? mnt; /* this is highly heuristic */
return [mnt, coqlib].filter(x => x).map(d => `-v${d}:${d}`);
}
......
......
......@@ -18,11 +18,11 @@
USER_ID=${LOCAL_USER_ID:-9001}
GROUP_ID=${LOCAL_GROUP_ID:-$USER_ID}
if [ x"$LOCAL_USER_ID" != x ] ; then
echo "Starting with UID : $USER_ID, GID: $GROUP_ID"
if [ -t 2 ] && [ x"$LOCAL_USER_ID" != x ] ; then
echo "# Starting with UID : $USER_ID, GID: $GROUP_ID" >&2
fi
groupadd -g $GROUP_ID thegroup
useradd --shell /bin/bash -u $USER_ID -g thegroup -o -c "" -m user
export HOME=/home/user
groupadd -g $GROUP_ID ateam
useradd --shell /bin/bash -u $USER_ID -g ateam -o -c "" -m jscoq
export HOME=/home/jscoq
exec /usr/sbin/gosu user:thegroup "${@:-bash}"
\ No newline at end of file
exec /usr/sbin/gosu jscoq:ateam "${@:-bash}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment