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

Support custom Procfile #27 #28

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 24 additions & 2 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@ export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"
cd $BUILD_DIR
dotnet --info

function publish() {
echo "publish $1"
dotnet publish $1 --output $2 --configuration Release --runtime linux-x64
}

if [ -e "$BUILD_DIR/Procfile" ]; then
numberOfProjects=0
while read line || [[ -n "$line" ]];
Copy link
Owner

Choose a reason for hiding this comment

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

Hi @WilhelmKleuSage

It does mean support of multiple projects? I think we can't do it, because only one web process instruction per file available

Copy link
Author

Choose a reason for hiding this comment

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

Apologies for the delay in reply, I was away.
The code iterates the entries in the Procfile, try to match a valid dll and then publish.
Use the count of valid projects to determine exit code.
While there can only be one web process type there can be multiple other arbitrarily named processes (worker processes).

do
if [[ $line =~ [0-9A-Za-z\.]+\.dll ]]; then
PROJECT_NAME=${BASH_REMATCH[0]%.dll}
publish $PROJECT_NAME $BUILD_DIR/heroku_output/$PROJECT_NAME
numberOfProjects=$((numberOfProjects+1))
fi
done < $BUILD_DIR/Procfile
if (($numberOfProjects > 0)); then
exit 0
else
echo "Procfile file found but no projects published"
exit 1
fi
fi

if [ -z ${PROJECT_FILE:-} ]; then
PROJECT_FILE=$(x=$(dirname $(find ${BUILD_DIR} -maxdepth 5 -iname Startup.cs | head -1)); while [[ "$x" =~ $BUILD_DIR ]] ; do find "$x" -maxdepth 1 -name *.csproj; x=`dirname "$x"`; done)
fi
Expand All @@ -48,8 +71,7 @@ if [ -z ${PROJECT_NAME:-} ]; then
PROJECT_NAME=$(basename ${PROJECT_FILE%.*})
fi

echo "publish ${PROJECT_FILE}"
dotnet publish $PROJECT_FILE --output ${BUILD_DIR}/heroku_output --configuration Release --runtime linux-x64
publish $PROJECT_FILE ${BUILD_DIR}/heroku_output

cat << EOT >> ${BUILD_DIR}/Procfile
web: cd \$HOME/heroku_output && ASPNETCORE_URLS='http://+:\$PORT' dotnet "./${PROJECT_NAME}.dll"
Expand Down