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

Docker workdir support #819

Merged
merged 12 commits into from
Aug 17, 2024

Conversation

jordanpwalsh
Copy link
Contributor

This adds an additional optional parameter to the "remote" configuration allowing the working directory to be set during invocation of docker exec. I was originally working around needing to execute the runCommand in an appropriate working directory by running a shell script but thought an option in the config would be beneficial to prevent needing to add those scripts to the source repository.

Testing output:

Relevant config:

"launch": {
	"remote": {
		"container": "${ContainerID}",
		"workdir": "/opt/app-root/src/pyluglite",
		"runCommand": ["pwd"]
	},
...

Output:

 /opt/app-root/src/pyluglite

@puremourning
Copy link
Owner

This change is Reviewable

@jordanpwalsh
Copy link
Contributor Author

Closing due to accidental code reformatting.

@jordanpwalsh
Copy link
Contributor Author

Re-opened with the file not completely reformatted.

@jordanpwalsh jordanpwalsh reopened this Dec 22, 2023
@puremourning
Copy link
Owner

Thanks for sending a PR but I fear this might be a slippery slope to implementing the entire compose file specification, or at least every argument to docker exec. I would prefer either:

  • just use simple command and run docker exec manually
  • add a docker_args or something akin to the ssh_args or whatever we already have.

@jordanpwalsh
Copy link
Contributor Author

jordanpwalsh commented Dec 22, 2023

If you prefer, I can implement your option 2 instead; I personally prefer that over a custom command. I would like to push back a little though. I can see your point about not wanting to implement a bunch of the compose spec, but I’d argue this isn’t quite that. The docker exec options are quite small — user id, env vars, and working directory — and I could easily see the other two being something to include as well. Working directory is just the one I happened to need at the time.

All that said. Your option of docker_args would suit me just fine too. I’m happy to help.

@puremourning
Copy link
Owner

That's sort of my point. It's a bit whack-a-mole. I'd rather have option 2 which is just a list of additional args passed to docker exec. Then I never have to change it again if/when docker or podman inevitably change or add something.

@jordanpwalsh
Copy link
Contributor Author

jordanpwalsh commented Dec 22, 2023 via email

@jordanpwalsh
Copy link
Contributor Author

I updated the branch per your feedback. I thought a format like below would be more intuitive, but opted to use docker_args from your original suggestion so existing configs aren't broken.

What I wanted:

"container": {
    "name": "string",
    "args": ["string", "string"]
}

What I did:

{
    "container": "string"
    "docker_args": ["string", "string"]
}

Copy link
Owner

@puremourning puremourning left a comment

Choose a reason for hiding this comment

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

I think what you wanted was fine, and probably better. We could have doe that with a "if it's an object, then ... else ..." but this is also ok.

:lgtm:

Reviewable status: 0 of 2 files reviewed, all discussions resolved

Copy link
Owner

@puremourning puremourning left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @jordanpwalsh)

Copy link
Contributor Author

@jordanpwalsh jordanpwalsh left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @jordanpwalsh)

@jordanpwalsh
Copy link
Contributor Author

@puremourning I fixed the couple linter complaints. Anything needing to be done about the failing test? Looks like the mac os test failing has been an ongoing thing.

Copy link
Contributor Author

@jordanpwalsh jordanpwalsh left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r3, 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @jordanpwalsh)

@puremourning
Copy link
Owner

I've kicked the CI. Fingers crossed 🤞

@puremourning
Copy link
Owner

Looks like a lint issue

@jordanpwalsh
Copy link
Contributor Author

@puremourning I don't have your flake8 config and no errors on my end, but I think I found what it was complaining about and fixed it.

Copy link
Contributor Author

@jordanpwalsh jordanpwalsh left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @jordanpwalsh)

@puremourning
Copy link
Owner

@Mergifyio rebase

Copy link
Contributor

mergify bot commented May 6, 2024

rebase

❌ Base branch update has failed

Git reported the following error:

Rebasing (1/8)
Auto-merging python3/vimspector/debug_session.py
CONFLICT (content): Merge conflict in python3/vimspector/debug_session.py
error: could not apply c3c2503... Added workdir support for docker exec
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply c3c2503... Added workdir support for docker exec

Copy link
Owner

@puremourning puremourning left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @jordanpwalsh)

Copy link
Contributor

mergify bot commented Aug 17, 2024

Thanks for sending a PR!

@mergify mergify bot merged commit af13695 into puremourning:master Aug 17, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants