Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3802313
D2342.id5899.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D2342.id5899.diff
View Options
diff --git a/roles/paas-docker/devel/files/arc.sh b/roles/paas-docker/devel/files/arc.sh
--- a/roles/paas-docker/devel/files/arc.sh
+++ b/roles/paas-docker/devel/files/arc.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
# -------------------------------------------------------------
# Phabricator — Arcanist Docker container wrapper
@@ -53,19 +53,40 @@
fi
if [ -d ~/.arc/ssh ]; then
- VOLUME_SSH="-v $HOME/.arc/ssh:/root/.ssh"
+ VOLUME_SSH="-v $HOME/.arc/ssh:/home/$USER/.ssh"
else
VOLUME_SSH=""
fi
+# -------------------------------------------------------------
+# Build image
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+test -v $UID && UID=$(id -u)
+test -v $GID && GID=$(id -g)
+IMAGE=nasqueron/arcanist:$UID-$GID
+
+build_image () {
+ BUILD_DIR=$(mktemp -d -t arc-build-XXXXXXXXXX)
+ pushd "$BUILD_DIR" > /dev/null || exit 1
+ >&2 echo "🔨 Building user-specific image $IMAGE for $USER"
+ echo "FROM nasqueron/arcanist" > Dockerfile
+ echo "RUN groupadd -r $USER -g $GID && mkdir /home/$USER && useradd -u $UID -r -g $USER -d /home/$USER -s /bin/bash $USER && chown -R $USER:$USER /home/$USER" >> Dockerfile
+ docker build -t "$IMAGE" .
+ popd > /dev/null
+ rm -rf "$BUILD_DIR"
+}
+
+test ! -z $(docker images -q "$IMAGE") || build_image
+
# -------------------------------------------------------------
# Run container
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [ $PRINT_LOG -eq 0 ]; then
- docker run $FLAGS --rm -v ~/.arc:/opt/config -v "$PWD:/opt/workspace" $VOLUME_SSH nasqueron/arcanist $COMMAND "$@"
+ docker run $FLAGS --rm --user $UID:$GID -v ~/.arc:/opt/config -v "$PWD:/opt/workspace" $VOLUME_SSH $IMAGE $COMMAND "$@"
else
- docker run $FLAGS -v ~/.arc:/opt/config -v "$PWD:/opt/workspace" $VOLUME_SSH nasqueron/arcanist $COMMAND "$@" > /dev/null
+ docker run $FLAGS --user $UID:$GID -v ~/.arc:/opt/config -v "$PWD:/opt/workspace" $VOLUME_SSH $IMAGE $COMMAND "$@" > /dev/null
sleep 3
docker logs "$INSTANCE"
docker rm "$INSTANCE" >/dev/null
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 09:38 (21 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2272768
Default Alt Text
D2342.id5899.diff (2 KB)
Attached To
Mode
D2342: Build Arcanist Docker images by user
Attached
Detach File
Event Timeline
Log In to Comment