Islandora-Devops / isle-site-template

Template for building and customising your institution's Islandora installation.
MIT License
5 stars 6 forks source link

Instructions for Developers using IDE #13

Open rosiel opened 1 year ago

rosiel commented 1 year ago

I just a lot of time developing code on my feature branch in the IDE, only to realize that I don't know how to get my changes out of docker and back into Github.

What I did:

What should I have done: ???

DonRichards commented 1 year ago

What I have done in the past and how I test PRs is changing the composer.json file and adding this. Just like a "vcs" but with type git you can specify the branch name as a "reference". This can also be a git tag value.

        {
            "type": "package",
            "package": {
                "name": "citation-style-language/styles-distribution",
                "version":"1.0.0",
                "source": {
                    "type": "git",
                    "url": "https://github.com/citation-style-language/styles-distribution.git",
                    "reference": "master"
                }
            }
        },

https://github.com/jhu-idc/idc-isle-dc/blob/development/codebase/composer.json#L82-L93

rosiel commented 1 year ago

Sorry I think I miscommunicated.

I was successful at checking out the feature branch of my code (though not with git history). My question is:

rosiel commented 1 year ago

from the Tech call, someone (won't say who) mentioned that to do it in the IDE, rm -rf the repo and git clone it. Then, you still have the issue of your github keys...

Annie mentioned that theres a command to copy files out of docker, which could work instead!

nigelgbanks commented 1 year ago

There are two docker-compose.yml files specific for OSX and Linux that allow the mounting of the SSH agent socket into the ide docker container.

The setup script detects the host OS and copies the appropriate file.

https://github.com/Islandora-Devops/isle-site-template/blob/a4e7021644a58d24d6ea6680887f4198be752402/setup.sh#L124-L128

This should allow you to use your GitHub SSH key, assuming you added it to your SSH-Agent.

nigelgbanks commented 1 year ago

Sorry I think I miscommunicated.

I was successful at checking out the feature branch of my code (though not with git history). My question is:

  • how do i get my desired branch as a git repo? (if that case, how do i set up my git credentials to automatically be used inside the ide/containers, because I scrap and bring up these dev instances all the time)
  • Or, how do i get the code out of the ide/containers and into a git repo I have (i.e. how do I scp)?

Composer is capable of doing this: https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository.

Alternatively, you can bind mount a local repository into the container.

https://docs.docker.com/storage/bind-mounts/

This is how the configuration changes get persisted to the host machine's hard disk.

nigelgbanks commented 1 year ago

Also, I should say there really isn't a reason to get things out of Docker. You can just work inside the container as if it were a VM, and use git inside of it.

The only concern is that you could accidentally destroy the container with your changes inside of it. If that is a concern for you, then I would suggest bind mounts.

rosiel commented 11 months ago

@nigelgbanks |This should allow you to use your GitHub SSH key, assuming you added it to your SSH-Agent.

Git works fine on my mac.

But it doesn't in the IDE.

First, every time I restart the docker containers i have to tell it my email and name.

And when i was ready to push to github, it gave me a popup with a one-time code that i was supposed to navigate to Github and paste in. There was no place to paste it in on Github. When I clicked the "Copy and navigate to Github" button, It did not take me to github (i.e. nothing appeared to happen).

Then the IDE froze after 5 minutes and needed to be restarted. #22

Then, after refreshing the browser, git push commands hang and nothing appears to happen.

nigelgbanks commented 6 months ago

You'll need to use ssh to connect with GitHub rather than https to have your credentials saved (https://docs.github.com/en/authentication/connecting-to-github-with-ssh). I'm not sure how you are using Git on your Mac, if your are not using ssh you would need to re-enter your password every time. Unless you're using some desktop or GUI application or some other 3rd party helper, I'm not familiar with.

nigelgbanks commented 6 months ago

I've just tested and this is indeed broken in the latest Docker for Mac though: https://github.com/docker/for-mac/issues/7204

nigelgbanks commented 6 months ago

Hmm, I really don't like the workarounds for this issue... might be that we just recommend folks mount their ~/.ssh directory, and we run a separate ssh-agent inside the IDE. They would have to enter their password again, and every time they restart the container... Things are so much easier on Linux...