Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install through installer script #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Preventing Windows related problems (i.e. when testing under docker)
* eol=lf
10 changes: 4 additions & 6 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ set -o pipefail # don't ignore exit codes when piping output
set -o nounset # fail on unset variables
unset GIT_DIR # Avoid GIT_DIR leak from previous build steps

if [ "$STACK" != "heroku-16" ]; then
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove this because with the script installer it is not needed.

echo "Need heroku-16 stack"
exit 1
fi

### Configure directories
BUILD_DIR=${1:-}
CACHE_DIR=${2:-}
Expand All @@ -23,6 +18,7 @@ cp $BP_DIR/profile/* $BUILD_DIR/.profile.d/

### Load dependencies
source $BP_DIR/lib/utils
topic "Building ASP.Net core application ..."

export_env_dir $ENV_DIR
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=${DOTNET_SKIP_FIRST_TIME_EXPERIENCE:-1}
Expand All @@ -35,7 +31,7 @@ echo "Installing dotnet"
install_dotnet $BUILD_DIR $CACHE_DIR

export PATH="/app/dotnet:${PATH}"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"


cd $BUILD_DIR
dotnet --info
Expand All @@ -51,6 +47,8 @@ fi
echo "publish ${PROJECT_FILE}"
dotnet publish $PROJECT_FILE --output ${BUILD_DIR}/heroku_output --configuration Release --runtime linux-x64



cat << EOT >> ${BUILD_DIR}/Procfile
web: cd \$HOME/heroku_output && ASPNETCORE_URLS='http://+:\$PORT' dotnet "./${PROJECT_NAME}.dll"
EOT
41 changes: 29 additions & 12 deletions lib/utils
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@

function install_dotnet() {
local BUILD_DIR="$1"
local CACHE_DIR="$2"
local ZIP_NAME="dotnet-2.1.4.tar.gz"
local CORE_CHANNEL="${2:-2.0}"
local INSTALL_SCRIPT="$CACHE_DIR/dotnet-install.sh"
local INSTALL_DIR="$CACHE_DIR/dotnet"

if [ ! -f $CACHE_DIR/$ZIP_NAME ]; then
# https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.0.5.md
curl -sSL -o $CACHE_DIR/$ZIP_NAME https://download.microsoft.com/download/1/1/5/115B762D-2B41-4AF3-9A63-92D9680B9409/dotnet-sdk-2.1.4-linux-x64.tar.gz
else
echo "$ZIP_NAME from cache folder"
topic "Installing .NET Core SDK"
if [ ! -d "$INSTALL_DIR" ]; then
if [ ! -d $CACHE_DIR ]; then
mkdir -p $CACHE_DIR
fi

# Get the installer
curl -sSL -o $INSTALL_SCRIPT https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh

# And made it executable
chmod +x $INSTALL_SCRIPT

export DOTNET_INSTALL_SKIP_PREREQS=1
$INSTALL_SCRIPT --install-dir $INSTALL_DIR --channel $CORE_CHANNEL
fi

mkdir -p ${BUILD_DIR}/.heroku/dotnet && tar zxf $CACHE_DIR/$ZIP_NAME -C ${BUILD_DIR}/.heroku/dotnet
ln -s ${BUILD_DIR}/.heroku/dotnet /app
# Copy it to the app directory
cp -R $INSTALL_DIR $BUILD_DIR/dotnet

ln -s $BUILD_DIR/dotnet /app
}

# https://github.com/ddollar/heroku-buildpack-apt
Expand Down Expand Up @@ -69,10 +81,10 @@ function apt_install(){
export LD_LIBRARY_PATH="$BUILD_DIR/.apt/usr/lib/x86_64-linux-gnu:$BUILD_DIR/.apt/usr/lib/i386-linux-gnu:$BUILD_DIR/.apt/usr/lib:${LD_LIBRARY_PATH-}"
export LIBRARY_PATH="$BUILD_DIR/.apt/usr/lib/x86_64-linux-gnu:$BUILD_DIR/.apt/usr/lib/i386-linux-gnu:$BUILD_DIR/.apt/usr/lib:${LIBRARY_PATH-}"
export INCLUDE_PATH="$BUILD_DIR/.apt/usr/include:${INCLUDE_PATH-}"
export CPATH="${INCLUDE_PATH-}"
export CPPPATH="${INCLUDE_PATH-}"
export CPATH="$INCLUDE_PATH"
export CPPPATH="$INCLUDE_PATH"
export PKG_CONFIG_PATH="$BUILD_DIR/.apt/usr/lib/x86_64-linux-gnu/pkgconfig:$BUILD_DIR/.apt/usr/lib/i386-linux-gnu/pkgconfig:$BUILD_DIR/.apt/usr/lib/pkgconfig:${PKG_CONFIG_PATH-}"
echo "APT packages Installled"
echo "APT packages Installed"
}

export_env_dir() {
Expand All @@ -89,3 +101,8 @@ export_env_dir() {
fi
fi
}

function valid_project() {
SDK_TYPE=`python3 -c "from xml.etree.ElementTree import ElementTree;import io;print(ElementTree(file=io.FileIO('$1')).getroot().attrib['Sdk'])"`
[ "$SDK_TYPE" = "Microsoft.NET.Sdk.Web" ]
}