Tweak plugin builds as to not require superuser permissions anywhere

This will keep all the build work done by the user who invokes the commands,
which allows for a little more development environment sanity. But only a little
bit more.
This commit is contained in:
R. Tyler Croy 2017-12-19 22:15:35 -08:00
parent 54476bab9f
commit c8af2844c8
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
5 changed files with 27 additions and 10 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
build/repos
webapp/
proxy/
assets/

View File

@ -18,7 +18,7 @@ builder: Dockerfile.builder
master: Dockerfile build/git-refs.txt agent-templates
docker build -t ${IMAGE_PREFIX}-$@ .
plugins: ./scripts/build-plugins plugins.txt builder
plugins: ./scripts/build-plugins plugins.yml builder
./scripts/build-plugins
build/git-refs.txt: plugins

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
BUILDER_CONTAINER="rtyler/codevalet-builder"
@ -17,13 +17,22 @@ if [ $? -eq 0 ]; then
TTY="-ti"
fi;
# Ensure ~/.m2 exists to avoid letting the Docker daemon create the directory
# owned by the root user
mkdir -p $HOME/.m2 $HOME/.npm $HOME/.cache
pushd $1
if [ -f pom.xml ]; then
echo ">> Building ${1}"
exec docker run --rm ${TTY} \
-v $HOME/.m2:/root/.m2 \
-u $(id -u):$(id -g) \
-e MAVEN_CONFIG=/var/maven/.m2 \
-v $HOME/.npm:/.npm \
-v $HOME/.cache:/.cache \
-v $HOME/.m2:/var/maven/.m2 \
-v $PWD:/data \
-w /data \
${BUILDER_CONTAINER} mvn install -e -B -DskipTests
${BUILDER_CONTAINER} \
mvn -Duser.home=/var/maven -e -B -U -DskipTests install
fi;
popd

View File

@ -5,6 +5,7 @@ REPOS_DIR=$BUILD_DIR/repos
SCRIPTS_DIR=$(realpath $(dirname $0))
PLUGINS_OUTPUT_DIR=$BUILD_DIR/plugins
BUILDER_CONTAINER="rtyler/codevalet-builder"
PATH=${SCRIPTS_DIR}:$PATH
mkdir -p $REPOS_DIR
mkdir -p $PLUGINS_OUTPUT_DIR
@ -52,9 +53,10 @@ pushd $REPOS_DIR
# https://issues.jenkins-ci.org/browse/JENKINS-45668
(cd js-libs-plugin && find . -maxdepth 1 -type d -exec mkdir -p {}/src/main/webapp/jsmodules \;)
for plugin in $(${SCRIPTS_DIR}/plugins-from-yaml $SCRIPTS_DIR/../plugins.yml); do
cloneWithDependencies $plugin
# Pipeling /dev/null into stdin for Docker to avoid stupidity with the tty, see:
# https://github.com/moby/moby/issues/8513
for plugin in $(${SCRIPTS_DIR}/plugins-from-yaml $SCRIPTS_DIR/../plugins.yml < /dev/null); do
cloneWithDependencies "${plugin}"
done;
# This was merged into the blueocean-plugin repository but still exists as a tombstone
@ -63,7 +65,7 @@ pushd $REPOS_DIR
set -e
for d in *-plugin; do
./scripts/build-plugin $d
${SCRIPTS_DIR}/build-plugin $d
done;
set +e

View File

@ -1,5 +1,7 @@
#!/bin/sh
ROOTDIR=$(realpath $(dirname $0)/../)
tty --quiet
if [ $? -eq 0 ]; then
@ -7,6 +9,6 @@ if [ $? -eq 0 ]; then
fi;
exec docker run --rm ${TTY} \
-v ${PWD}:${PWD} \
-w ${PWD} \
-v ${ROOTDIR}:${ROOTDIR} \
-w ${ROOTDIR} \
ruby:2-alpine $@