Skip to content

Commit

Permalink
Enable docker support for centos builds
Browse files Browse the repository at this point in the history
- Added an option '--buildindocker <osname>' to build.sh
- Fixed bug which caused packaging to be skipped by default.
- Fixed bug which caused tarballs to be generated twice.
- Fixed bug to propagate build params(like debug, nopackage) to docker build.
  • Loading branch information
Sridhar-MS committed Jan 8, 2016
1 parent fee3785 commit 5155aa6
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 61 deletions.
18 changes: 11 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ source "$REPOROOT/scripts/build/process-args.sh"
# once that is fixed, we should remove the NOPACKAGE flag and do the full build either in
# or out of docker.
if [ ! -z "$BUILD_IN_DOCKER" ]; then
export BUILD_COMMAND="/opt/code/scripts/build/build.sh NOPACKAGE"
export BUILD_COMMAND=". /opt/code/scripts/build/process-args.sh $@ ; . /opt/code/scripts/build/build.sh"
$REPOROOT/scripts/docker/dockerbuild.sh
else
$REPOROOT/scripts/build/build.sh NOPACKAGE
$REPOROOT/scripts/build/build.sh
fi

if [ ! -z "$PACKAGE_IN_DOCKER" ]; then
export BUILD_COMMAND="/opt/code/scripts/package/package-native.sh"
$REPOROOT/scripts/docker/dockerbuild.sh
if [ ! -z "$NOPACKAGE" ]; then
header "Skipping packaging"
else
$REPOROOT/scripts/package/package.sh
fi
if [ ! -z "$PACKAGE_IN_DOCKER" ]; then
export BUILD_COMMAND="$REPOROOT/scripts/package/package.sh"
$REPOROOT/scripts/docker/dockerbuild.sh
else
$REPOROOT/scripts/package/package.sh
fi
fi
10 changes: 0 additions & 10 deletions scripts/build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,3 @@ DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $REPOROOT/scripts/test/runtests

header "Validating Dependencies"
$REPOROOT/scripts/test/validate-dependencies.sh

header "Generating tarball"
$REPOROOT/scripts/package/package.sh

if [ ! -z "$NOPACKAGE" ]; then
header "Generating Native Installer"
$REPOROOT/scripts/package/package-native.sh
else
header "Skipping packaging"
fi
22 changes: 14 additions & 8 deletions scripts/build/process-args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,31 @@
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#

for i in "$@"
params=("$@")

for i in "${!params[@]}"
do
lowerI="$(echo $i | awk '{print tolower($0)}')"
lowerI="$(echo ${params[$i]} | awk '{print tolower($0)}')"
case $lowerI in
release)
"release" | "-release")
export CONFIGURATION=Release
;;
debug)
"debug" | "-debug")
export CONFIGURATION=Debug
;;
offline)
"offline" | "-offline")
export OFFLINE=true
;;
nopackage)
"nopackage" | "-nopackage")
export NOPACKAGE=true
;;
nocache)
"nocache" | "-nocache")
export NOCACHE=--No-Cache
;;
"--buildindocker")
export BUILD_IN_DOCKER=true
export DOCKER_OS=${params[i+1]}
;;
*)
esac
done
done
16 changes: 8 additions & 8 deletions scripts/ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ if [ -z "$HOME" ]; then
mkdir -p $HOME
fi

# Set Docker Container name to be unique
container_name=""

#Jenkins
[ ! -z "$BUILD_TAG" ] && container_name="$BUILD_TAG"
#VSO
[ ! -z "$BUILD_BUILDID" ] && container_name="$BUILD_BUILDID"

if [[ "$OSNAME" == "ubuntu" ]]; then
# Set Docker Container name to be unique
container_name=""
export DOTNET_BUILD_CONTAINER_NAME="$container_name"

#Jenkins
[ ! -z "$BUILD_TAG" ] && container_name="$BUILD_TAG"
#VSO
[ ! -z "$BUILD_BUILDID" ] && container_name="$BUILD_BUILDID"

export DOTNET_BUILD_CONTAINER_NAME="$container_name"
if [[ "$OSNAME" == "ubuntu" ]]; then
export PACKAGE_IN_DOCKER="true"
export NOCACHE="--no-cache"
unset BUILD_IN_DOCKER
Expand Down
1 change: 0 additions & 1 deletion scripts/common/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
done
COMMONDIR="$( cd -P "$( dirname "$COMMONSOURCE" )" && pwd )"

source "$COMMONDIR/_clang.sh"
source "$COMMONDIR/_prettyprint.sh"
source "$COMMONDIR/_rid.sh"

Expand Down
1 change: 1 addition & 0 deletions scripts/compile/compile-corehost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

source "$DIR/../common/_common.sh"
source "$DIR/../common/_clang.sh"

header "Building corehost"

Expand Down
49 changes: 49 additions & 0 deletions scripts/docker/centos/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# 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.
#

# Dockerfile that creates a container suitable to build dotnet-cli
FROM centos:7.1.1503

RUN yum -q -y install deltarpm
RUN yum -q -y install epel-release
# RUN yum -y update

# This could become a "microsoft/coreclr" image, since it just installs the dependencies for CoreCLR (and stdlib)
# Install CoreCLR and CoreFx dependencies
RUN yum -q -y install unzip libunwind gettext libcurl-devel openssl-devel zlib libicu-devel

# RUN apt-get update && \
# apt-get -qqy install unzip curl libicu-dev libunwind8 gettext libssl-dev libcurl3-gnutls zlib1g liblttng-ust-dev lldb-3.6-dev lldb-3.6

# Install Build Prereqs
RUN yum -q -y install tar git cmake clang make

# Use clang as c++ compiler
RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
RUN update-alternatives --set c++ /usr/bin/clang++

# Install azure cli. We need this to publish artifacts.
RUN yum -y install nodejs && \
yum -y install npm && \
npm install -g azure-cli


RUN yum -q -y install sudo

# Setup User to match Host User, and give superuser permissions
ARG USER_ID=0
RUN useradd -m code_executor -u ${USER_ID} -g root
RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# With the User Change, we need to change permssions on these directories
RUN chmod -R a+rwx /usr/local
RUN chmod -R a+rwx /home
RUN chmod -R 755 /usr/bin/sudo

# Set user to the one we just created
USER ${USER_ID}

# Set working directory
WORKDIR /opt/code
8 changes: 5 additions & 3 deletions scripts/docker/dockerbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ 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 "$BUILD_COMMAND" ] && BUILD_COMMAND="/opt/code/build.sh"
[ -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 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"
Expand All @@ -43,4 +44,5 @@ docker run -t --rm --sig-proxy=true \
-e REPO_USER \
-e REPO_PASS \
-e REPO_SERVER \
$DOTNET_BUILD_CONTAINER_TAG $BUILD_COMMAND $1
$DOTNET_BUILD_CONTAINER_TAG \
bash -c "${BUILD_COMMAND}"
File renamed without changes.
29 changes: 5 additions & 24 deletions scripts/package/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,11 @@ source "$DIR/../common/_common.sh"

if [ -z "$DOTNET_BUILD_VERSION" ]; then
TIMESTAMP=$(date "+%Y%m%d%H%M%S")
DOTNET_BUILD_VERSION=0.0.1-alpha-t$TIMESTAMP
DOTNET_BUILD_VERSION=0.0.1-dev-t$TIMESTAMP
fi

STAGE2_DIR=$REPOROOT/artifacts/$RID/stage2
header "Generating tarball"
$DIR/package-dnvm.sh

if [ ! -d "$STAGE2_DIR" ]; then
error "missing stage2 output in $STAGE2_DIR" 1>&2
exit
fi

PACKAGE_DIR=$REPOROOT/artifacts/packages/dnvm
[ -d "$PACKAGE_DIR" ] || mkdir -p $PACKAGE_DIR

PACKAGE_SHORT_NAME=dotnet-${OSNAME}-x64.${DOTNET_BUILD_VERSION}
PACKAGE_NAME=$PACKAGE_DIR/${PACKAGE_SHORT_NAME}.tar.gz

cd $STAGE2_DIR

header "Packaging $PACKAGE_SHORT_NAME"

# Tar up the stage2 artifacts
# We need both "*" and ".version" to ensure we pick up that file
tar -czf $PACKAGE_NAME * .version

info "Packaged stage2 to $PACKAGE_NAME"

$REPOROOT/scripts/publish/publish.sh $PACKAGE_NAME
header "Generating Native Installer"
$DIR/package-native.sh

0 comments on commit 5155aa6

Please sign in to comment.