Navigation Menu

Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

Commit

Permalink
Tweak plugin builds as to not require superuser permissions anywhere
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
R. Tyler Croy committed Dec 20, 2017
1 parent 54476ba commit c8af284
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
@@ -0,0 +1,4 @@
build/repos
webapp/
proxy/
assets/
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions scripts/build-plugin
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

BUILDER_CONTAINER="rtyler/codevalet-builder"

Expand All @@ -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
10 changes: 6 additions & 4 deletions scripts/build-plugins
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions scripts/ruby
@@ -1,12 +1,14 @@
#!/bin/sh

ROOTDIR=$(realpath $(dirname $0)/../)

tty --quiet

if [ $? -eq 0 ]; then
TTY="-ti"
fi;

exec docker run --rm ${TTY} \
-v ${PWD}:${PWD} \
-w ${PWD} \
-v ${ROOTDIR}:${ROOTDIR} \
-w ${ROOTDIR} \
ruby:2-alpine $@

0 comments on commit c8af284

Please sign in to comment.