working on build scripts
This commit is contained in:
parent
f273ea4f7d
commit
d524732bbb
111 changed files with 3052 additions and 1989 deletions
|
@ -1,48 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/../common/_common.sh"
|
||||
|
||||
cd $REPOROOT
|
||||
|
||||
[ -z "$DOTNET_BUILD_CONTAINER_TAG" ] && DOTNET_BUILD_CONTAINER_TAG="dotnetcli-build"
|
||||
[ -z "$DOTNET_BUILD_CONTAINER_NAME" ] && DOTNET_BUILD_CONTAINER_NAME="dotnetcli-build-container"
|
||||
[ -z "$DOCKER_HOST_SHARE_DIR" ] && DOCKER_HOST_SHARE_DIR=$(pwd)
|
||||
[ -z "$DOCKER_OS" ] && DOCKER_OS=$OSNAME
|
||||
[ -z "$BUILD_COMMAND" ] && BUILD_COMMAND="/opt/code/scripts/build/build.sh"
|
||||
|
||||
# Build the docker container (will be fast if it is already built)
|
||||
header "Building Docker Container"
|
||||
docker build --build-arg USER_ID=$(id -u) -t $DOTNET_BUILD_CONTAINER_TAG scripts/docker/$DOCKER_OS
|
||||
|
||||
# Run the build in the container
|
||||
header "Launching build in Docker Container"
|
||||
info "Using code from: $DOCKER_HOST_SHARE_DIR"
|
||||
docker run -t --rm --sig-proxy=true \
|
||||
--name $DOTNET_BUILD_CONTAINER_NAME \
|
||||
-v $DOCKER_HOST_SHARE_DIR:/opt/code \
|
||||
-e DOTNET_CLI_VERSION \
|
||||
-e SASTOKEN \
|
||||
-e STORAGE_ACCOUNT \
|
||||
-e STORAGE_CONTAINER \
|
||||
-e CHANNEL \
|
||||
-e CONNECTION_STRING \
|
||||
-e REPO_ID \
|
||||
-e REPO_USER \
|
||||
-e REPO_PASS \
|
||||
-e REPO_SERVER \
|
||||
$DOTNET_BUILD_CONTAINER_TAG \
|
||||
bash -c "${BUILD_COMMAND}"
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/../_common.sh"
|
||||
|
||||
cd $REPOROOT
|
||||
|
||||
[ -z "$DOTNET_BUILD_CONTAINER_TAG" ] && DOTNET_BUILD_CONTAINER_TAG="dotnetcli-build"
|
||||
[ -z "$DOTNET_BUILD_CONTAINER_NAME" ] && DOTNET_BUILD_CONTAINER_NAME="dotnetcli-build-container"
|
||||
[ -z "$DOCKER_HOST_SHARE_DIR" ] && DOCKER_HOST_SHARE_DIR=$(pwd)
|
||||
|
||||
# Enter the container
|
||||
docker run -it --rm --sig-proxy=true \
|
||||
-v $DOCKER_HOST_SHARE_DIR:/opt/code \
|
||||
$DOTNET_BUILD_CONTAINER_TAG
|
|
@ -1,110 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
# Prerequisites:
|
||||
# Git Bash (http://www.git-scm.com/downloads)
|
||||
# Docker Toolbox (https://www.docker.com/docker-toolbox)
|
||||
# Ensure Hyper-V is disabled!
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
# This function is necessary to bypass POSIX Path Conversion in Git Bash
|
||||
# http://www.mingw.org/wiki/Posix_path_conversion
|
||||
_convert_path(){
|
||||
local path=$1
|
||||
path=$( echo "$path" | sed -r 's/[\/]+/\\/g')
|
||||
path=${path#\\}
|
||||
path=//$path
|
||||
|
||||
echo $path
|
||||
}
|
||||
|
||||
# Bypass Msys path conversion
|
||||
REPO_ROOT=$(readlink -f $DIR/../..)
|
||||
REPO_ROOT=$(_convert_path $REPO_ROOT)
|
||||
|
||||
VM_NAME="dotnet"
|
||||
VM_CODE_DIR="/home/docker/code"
|
||||
|
||||
RESULTS_DIR="$REPO_ROOT/artifacts"
|
||||
|
||||
execute(){
|
||||
check_prereqs
|
||||
|
||||
echo "Setting up VM..."
|
||||
create_or_start_vm
|
||||
|
||||
echo "Copying code from Host to VM"
|
||||
eval $(docker-machine env --shell bash $VM_NAME)
|
||||
copy_code_to_vm
|
||||
|
||||
echo "Running Build in Docker Container"
|
||||
run_build
|
||||
|
||||
echo "Copying Results from VM to Hosts..."
|
||||
copy_results_from_vm
|
||||
}
|
||||
|
||||
check_prereqs(){
|
||||
if ! which docker; then
|
||||
echo "Error: Install docker toolbox (https://www.docker.com/docker-toolbox)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! which docker-machine; then
|
||||
echo "Error: Install docker toolbox (https://www.docker.com/docker-toolbox)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
create_or_start_vm(){
|
||||
|
||||
if [[ $(docker-machine ls | grep $VM_NAME) == "" ]]; then
|
||||
docker-machine create -d virtualbox $VM_NAME
|
||||
else
|
||||
# This fails sometimes
|
||||
if ! docker-machine start $VM_NAME; then
|
||||
docker-machine rm -f $VM_NAME
|
||||
docker-machine create -d virtualbox $VM_NAME
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
copy_code_to_vm(){
|
||||
docker-machine ssh $VM_NAME "sudo rm -rf $VM_CODE_DIR"
|
||||
docker-machine scp -r $REPO_ROOT $VM_NAME:$VM_CODE_DIR >> /dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
run_build(){
|
||||
# These are env variables for dockerbuild.sh
|
||||
export DOCKER_HOST_SHARE_DIR="$(_convert_path $VM_CODE_DIR)"
|
||||
export BUILD_COMMAND="//opt\\code\\build.sh"
|
||||
|
||||
$DIR/../dockerbuild.sh debian
|
||||
}
|
||||
|
||||
# This will duplicate the entire repo + any side effects from
|
||||
# the operations in the docker container
|
||||
copy_results_from_vm(){
|
||||
T_RESULTS_DIR=$( echo "$RESULTS_DIR" | sed -r 's/[\\]+/\//g')
|
||||
T_RESULTS_DIR=${T_RESULTS_DIR#/}
|
||||
|
||||
mkdir $T_RESULTS_DIR
|
||||
docker-machine ssh $VM_NAME "sudo chmod -R a+rx $VM_CODE_DIR"
|
||||
docker-machine scp -r $VM_NAME:$VM_CODE_DIR/artifacts $REPO_ROOT >> /dev/null 2>&1
|
||||
}
|
||||
|
||||
execute
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue