jincod / dotnetcore-buildpack

Heroku .NET Core Buildpack
MIT License
750 stars 360 forks source link

Get rid of "cd" in Prodfile for interoperability with herokuish #145

Closed DCNick3 closed 2 years ago

DCNick3 commented 3 years ago

Herokuish is an implementation of heroku buildpacks logic used, for example, in Dokku - a self-hosted PaaS providing similar features to heroku.

This buildpack seems to work fine with it, but, unfortunately, it uses exec to run the command that is put in Procfile, which fails miserably when used with Procfile generated by this project, containing something like cd $HOME/heroku_output && ./app_executable. If it is replaced with $HOME/heroku_output/app_executable - it works fine.

I think it might be a good idea to change it so that it will work with herokuish and dokku.

As a workaround one can use custom Procfile with something like web: $HOME/heroku_output/app_executable in it.

DCNick3 commented 3 years ago

Seems that some user has already experienced this error in dokku/dokku#3253

jrhodnik commented 2 years ago

I forked this repo and did the suggestions above however this does mess with the working directory which will likely break apps. Adding something like Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); to the entry point resolves this but it is still a breaking change so it's probably not worth a PR here. As suggested above the best solution is for herokuish to change how they handle Procfile execution.

DCNick3 commented 2 years ago

I've also tried playing around with bash -c 'command', but it didn't work for some reason (maybe I am stupid or shell escaping gone haywire)

web: $HOME/heroku_output/app_executable worked for me because I don't care about the working directory, but yeah, if you need it - you can change it in C# as a workaround

jincod commented 2 years ago

Hello @DCNick3 @jrhodnik

I've done some changes

Could you please check does it work for you?

heroku config:set HEROKUISH=true
heroku buildpacks:set https://github.com/jincod/dotnetcore-buildpack#feature/herokuish
jrhodnik commented 2 years ago

Just got a chance to test this. Here's the result. Is this my environment, or something else maybe?

remote:        Add web process to Procfile
remote:        Override Procfile for herokuish
remote:        Using release configuration from last framework (ASP.NET Core).
remote:        -----> Discovering process types
remote:        Procfile declares types -> web
remote: -----> Releasing rap-master...
remote: -----> Checking for predeploy task
remote:        No predeploy task found, skipping
remote: -----> Checking for release task
remote:  !     process names must be unique, line 2
remote: 2021/10/07 22:06:32 exit status 1
remote: -----> App Procfile file found
remote:        No release task found, skipping
remote: -----> App Procfile file found
remote:  !     process names must be unique, line 2
remote: 2021/10/07 22:06:36 exit status 1
remote:  !     exit status 1
remote: 2021/10/07 22:06:36 exit status 1
remote: 2021/10/07 22:06:36 exit status 1
remote: 2021/10/07 22:06:36 exit status 1
jincod commented 2 years ago

Thank you @jrhodnik

It should be fixed now

jrhodnik commented 2 years ago

It does seem to work now! Still requires the little hack regarding changing working directories above, however I'm not sure there's much we can do about that without actual access to cd.

Thank you, @jincod !

jincod commented 2 years ago

Merged to master. Updated README

Thank you for your contribution!