-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Use Procfile for process types in Dockerfile apps #1915
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
Use Procfile for process types in Dockerfile apps #1915
Conversation
|
Tests pass. Can you add docs for this so I can compare it to what we think it should do/our current handling of dockerfile deploys? This is obviously a breaking change, so I'm curious as to what the impact might be on our users. |
|
Will do. I'll try to get that done tonight.
|
|
I could also make this feature off by default and enabled via an environment variable. So something like |
|
No, I think we should roll it out by default. We break functionality in 0.5.x, so no need to keep BC. Ideally if it works one way on heroku, it works that way on dokku. What should happen if we define an entry point? |
|
The way it's written is that the entries in the Procfile would be run as arguments to the entrypoint script. I think as long as it's documented that providing a Procfile with a Dockerfile deployment means that the commands in the Procfile are used as the argument to |
All I request is that so long as there's no |
|
@mmerickel that is the idea for sure. @josegonzalez my first pass at documentation is in. |
|
@mmerickel and since it actually won't have any effect unless it's in the docker image, you could add |
plugins/ps/pre-deploy
Outdated
|
|
||
| APP="$1" | ||
|
|
||
| get_procfile $APP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need a herokuish app's Procfile. Can we only extract the Procfile in the necessary case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched the generate_scale_file function to use the local Procfile extracted by this step, so it is used in either case. I figured it'd be the best thing since it was being extracted by that command anyway but thrown away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I missed that. Personally, I'd like to get away from cluttering the /home/dokku/APP directory. However, I believe that concern is being addressed in another issue (#1558)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, if you'd prefer I can revert generate_scale_file changes and only do this for dockerfile apps, but it would mean double extraction for dockerfile apps to generate the scale file and save the procfile for use by dokku deploy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll defer to @josegonzalez
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we delete the file if it's from a dockerfile deploy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean @josegonzalez. We need it in both cases for generating the scale file, and especially in dockerfile deploy for discovering what commands to run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant in the /home/dokku/APP directory, and only extract it when necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could probably do that, or could go back to never storing it and reading it from the image every time. It just seemed like a useful pattern to keep info necessary for starting containers in app dir like the SCALE file is.
|
I tried an experiment on Heroku with a Dockerfile with an |
|
Yeah that's the conversation I'd like to have on #1564 |
|
I personally feel it's a heroku bug rather than how they'd like it to work. They don't (can't) support the full docker feature-set, but dokku can do a better job. If we're going to ignore Procfiles for all but buildpack deployments then we need a better solution than the |
|
@pmclanahan would you mind bringing this discussion to #1564? |
|
Just did |
|
Gracias! |
|
Just added |
|
Ah. NM. I see that was later removed and |
|
@pmclanahan Yeah, remove that please :) |
36d2b72 to
0eb34ef
Compare
|
gone |
dokku
Outdated
| if [[ -z "$START_CMD" ]]; then | ||
| # get cmd from Procfile | ||
| START_CMD=$(get_cmd_from_procfile $APP $PROC_TYPE) | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe shorten this block to:
DOKKU_DOCKERFILE_START_CMD=$(dokku config:get $APP DOKKU_DOCKERFILE_START_CMD)
DOKKU_PROCFILE_START_CMD=$(get_cmd_from_procfile $APP $PROC_TYPE)
START_CMD=${DOKKU_DOCKERFILE_START_CMD:-$DOKKU_PROCFILE_START_CMD}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config_get, not dokku config:get.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's the new standard. I don't think that code has been refactored yet
DOKKU_DOCKERFILE_START_CMD=$(config_get $APP DOKKU_DOCKERFILE_START_CMD)
DOKKU_PROCFILE_START_CMD=$(get_cmd_from_procfile $APP $PROC_TYPE)
START_CMD=${DOKKU_DOCKERFILE_START_CMD:-$DOKKU_PROCFILE_START_CMD}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll also need to add this line under the source command for common/functions
source "$PLUGIN_ENABLED_PATH/common/functions"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that. It's updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll also need to add this line under the source command for common/functions
You mean up around line 35? Does that not include the functions from the common plugin?
f0cb5e5 to
cafad6e
Compare
docs/deployment/dockerfiles.md
Outdated
| will be started basically using the command `docker run bin/run-prod.sh`. If you want to also run | ||
| a worker container for this app, you can run `dokku ps:scale worker=1` and a new container will be | ||
| started by running `docker run bin/run-worker.sh` (the actual `docker run` commands are a bit more | ||
| complex, but this is the basic idea). So if you use an `ENTRYPOINT` in your `Dockerfile` the lines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comma after Dockerfile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the So part of this sentence.
4c8b97f to
72e6899
Compare
|
Rebased to fix merge conflict and updated docs based on feedback. |
|
We keep the scale file because we can set it via the command line as well as ship it with the app. No need to keep the Procfile around really |
|
So maybe keep things as they are but remove the file in |
plugins/ps/post-deploy
Outdated
| APP="$1" | ||
| DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE" | ||
|
|
||
| [ -f "$DOKKU_PROCFILE" ] && rm -f "$DOKKU_PROCFILE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josegonzalez @michaelshobbs like so?
63c77bb to
9d3c893
Compare
plugins/ps/post-deploy
Outdated
| APP="$1" | ||
| DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE" | ||
|
|
||
| [[ -f "$DOKKU_PROCFILE" ]] && rm -f "$DOKKU_PROCFILE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a simple way to do this in pre-deploy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file is primarily needed in the deploy command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I meant to say in the deploy phase. IIRC, you call get_cmd_from_procfile() in dokku's deploy phase. Thus, perhaps we can do everything in one swing as opposed to extracting the Procfile in pre-deploy, using it in deploy and removing it in post-deploy.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's extracted in pre-deploy currently because generate_scale_file which is in pre-deploy now uses the extracted file. Thus it makes sense to do cleanup in post-deploy. We could of course move all of this into deploy in the dokku executable, but I don't see a down side of keeping it as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And actually extract_procfile is probably a better function name than get_procfile. I can change it to be more explicit, and add a cleanup_procfile or remove_procfile function to make post-deploy cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable. Thanks for talking it out.
d896d79 to
1252a20
Compare
tests/unit/10_ps-dockerfile.bats
Outdated
| } | ||
|
|
||
| @test "(ps:scale) procfile commands extraction" { | ||
| deploy_app dockerfile-procfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems to be doing double duty given we already test the deployment of this app type in the previous test.
Instead, I recommend running create_app, generating a Procfile manually at $DOKKU_ROOT/$TEST_APP/DOKKU_PROCFILE and then running the get_cmd_from_procfile() tests. This way we don't waste the cycles testing something other than the specific thing we want to test. We follow this pattern in the Dockerfile port extraction tests. https://github.com/dokku/dokku/blob/v0.4.13/tests/unit/30_core_ports_2.bats#L100-L124
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch. updated and pushed to my branch.
1252a20 to
4d4e41b
Compare
|
For some reason github isn't indicating the passing test run. But it did pass. So hopefully we're nearly done here? |
* Document new Procfile feature * Add and update tests * Fix a typo in generate_scale_file (ref dokku#1923)
4d4e41b to
162a50a
Compare
|
lgtm |
|
Ship it at your leisure, @michaelshobbs. |
…ile-deploy Use Procfile for process types in Dockerfile apps
|
Note: I backed out this change while I attempt to make a release of dokku for 0.4.x. This change will ship with 0.5.x. |
|
Alright, it's now in master :) |
|
W00t! 🍰 Thanks guys! Pleasure working with ya. |
|
No no, thank you @pmclanahan 👊 |
|
If I specify |
|
Also, it doesn't seem to run the |
|
@vladfaust pleas file a new issue rather than commenting on an 8 year old closed one. Thank you. |
This is my initial attempt at fixing #1564. I'm opening a PR now to see how the tests in CI go and to get some feedback on direction. If I need to be doing something different I figured earlier was better than later to find that out.
Still todo: