-
Notifications
You must be signed in to change notification settings - Fork 16
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
Container not re-used on code change #6
Comments
It will build a new image for every change, yes. When running, you may want to pass the '--rm' flag to docker so terminated containers are cleaned up automatically. |
I am just wondering what a good debug strategy would be as I would need to rerun the debugger to attach again after every code change. Right? Can IDEs understand PEX files for debugging purposes anyway? |
See https://www.pantsbuild.org/docs/python-run-goal#debugging for info on how to do this outside of |
What is your setup here? I mean, what does the Docker container give you that running the Pex/code directly doesn't when debugging? |
I am used to running my applications in a isolated environments, i.e. Docker containers so that I can replicate my production environment as much as possible and that seems a best practice in the container world. One other setup might be to use https://github.com/localstack/localstack for running the applications, even though pants build/publish is used instead of pants run. What is the intended use case for the pants run command for a docker target? |
Got it. +1 for having a production like environment for testing, however depending on the change/build/test cycle time for such a setup, being able to also develop under a less strict environment may be worth considering. (I don't have experience developing for cloud services, so that remark may be off by some degree..)
The For tighter integration with the Pants-world, and the use case you describe, I think may be covered by pantsbuild/pants#13682 which you've discovered earlier ;) |
So I tried the
Any idea? I would like to investigate how to attach a VSCode debugger to the container and I might need to identify the container and thought the name seems a good option. |
Ah, so docker doesn't remove the old container quick enough. Another option, going down this route, could be to write out the container id to a file mounted from the host, and monitor that file for changes should allow the connection with VSCode to be kept up-to-date, hopefully (no idea how that connection works) |
That is a good hint. Another option could be using the label and filter for it. In general, the debug setup for VSCode seems to be different than with IntelliJ, where you run a debug server from the code. For VSCode, it looks like it runs the app and hooks into the process. That is why I was asking for debugging PEX in general as I am not sure VSCode can be configured to understand this. There seems to be options where we might be able to specify that pants should run the container. I will try to investigate this and any hints are very appreciated. In theory, is it possible to not use pants code reloading but mount the source code to the container and use it that way for within the PEX File? |
I think you'd have to leave the Pants world entirely for that, as it is. |
It should work for the AWS Lambda case though as here the PEX will be unzipped: So there is no current possibility to achieve this in a similiar way for just a normal PEX file? As a new feature I could think of something like a |
Ah, yes. That is interesting. So the image is used more as a side-effect/or means for debugging, rather than build me an image, and then I want to run it. IIUC we'd want to be able to say "continuously build this target, and volume mount it into a container based on this image running command x". Effectively setting up one container with one command with the built artifact volume mounted into the container, and replace the artifact on any source changes while keeping the container running. I think that's doable. |
@thejcannon does any of the above fit with the |
I think so? I'm only partially grokking the discussion, but if you're trying to VS Code debug some code, the I owe Pants the docs for this, but I'm waiting for |
@thejcannon I had a look and the @kaos What I have missed with the mentioned AWS Lambda example: Yes, the hot code reloading should work that way, but of course any third party or internal lib changes will not be recognized.
Yes, that is absolutely right. The image is, in the best case, the production image and I want to run my code with pants in that container for developing/debugging the application. With the With the current implementation of So yes, I could think of the following workflow for
What are your thoughts? Should I open a feature request? |
That aligns with my current understanding. My reference to the debug adapter here would be more of an implementation detail (and possibly UX) not functionality. I think we can work with this issue as the feature request, but feel free to write a new one if that makes better sense to you :) |
Oh, just realized this issue is not in the pants repo, so yes a feature request over in pantsbuild/pants would be great, thank you. |
I have been trying this example and wanted to check whether hot code reloading also works when running the Docker container with pants. What I noticed is, that on every code change a new container is run. For a lot of code changes, this would spin up a lot of containers. Am I missing something to be configured?
The text was updated successfully, but these errors were encountered: