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

Add devcontainer and Github Codespaces setup #43

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

cleverer
Copy link
Contributor

@cleverer cleverer commented Mar 25, 2023

Just works ;) (If you don't know how, check the docs)

After merging it would make sense to set up prebuilds: https://docs.github.com/en/codespaces/prebuilding-your-codespaces/configuring-prebuilds

I'd recommend to run weekly rebuilds I guess.

Prebuilds run on Github Actions which is free for public repositories, so no additional costs. Only storage for the prebuilt images is not enough with 15GB…

@cleverer cleverer force-pushed the devcontainer branch 10 times, most recently from fa08dcb to c1a61f3 Compare March 25, 2023 19:00
@cleverer cleverer changed the title WIP: add devcontainer add devcontainer Mar 26, 2023
@cleverer cleverer marked this pull request as ready for review March 26, 2023 15:36
@kronn kronn requested review from mtnstar and carlobeltrame August 16, 2023 12:23
BacLuc and others added 5 commits March 8, 2024 23:37
# Conflicts:
#	.gitignore
#	docker/rails.dockerfile
Else you need to accept the public key of github.com,
which needs interaction.
Merge hitobito/development into cleverer/devcontainer
@cleverer cleverer changed the title add devcontainer Add devcontainer and Github Codespaces setup Mar 11, 2024
@cleverer
Copy link
Contributor Author

cleverer commented Mar 11, 2024

This PR has been reworked and optimized. Thanks to @BacLuc, @petter1 and all the others for their inputs and help!

New since the last time:

  • Docker containers now wait for each other using docker healthchecks. This makes the waitfortcp in the entrypoints obsolete.
  • Github SSH Host keys are preregistered in the docker container, simplifying pulling via ssh.
  • Replace mysql with corresponding mariadb. (Yay arm-based machines 🎉 )
  • Don't mount the whole home directory outside the container. That leads to a lot of confusing behaviour…
  • Don't mount the X11 socket by default, as it causes issues on multiple platforms (arch, macos on Apple Silicon…)
  • Allow to access docker from within the dev container

Currently not working:

  • If you run the Github Codespace in the Browser and access hitobito, CORS is not set up correctly.
  • Debugging inside the container requires a merge of fix(Gemfile): pin json gem below 2.7.0 hitobito#2478
  • The prebuilt images currently seem a bit finicky. If in doubt do a full rebuild as described in docs/Devcontainer.md and grab a coffee ;)

TODOs for Puzzle

  • After merging this, it would be wonderful if pre-builds would be setup, for that truly instant first time setup.
  • It would be lovely if a .github Repository could be created on the hitobito org. There you could add links like this:
    • https://github.com/codespaces/new?ref=devcontainer&repo=277813823&machine=basicLinux32gb&geo=EuropeWest&devcontainer_path=.devcontainer%2Fgeneric%2Fdevcontainer.json
    • This allows people to directly launch a codespace.
    • You can list all possible variants, just change the devcontainer_path param accordingly.
  • Update the list of variants/setups aka update .devcontainerconfigs.

If you have questions about how it "just works", check the docs/Devcontainer.md and docs/DevcontainerInDepth.md ;)

@carlobeltrame I think I'm through with reworking, feel free to review and request more docs! Also: Feel free to squash when merging, there's a lot of trial and error here… ^^

@cleverer
Copy link
Contributor Author

Update for all interested in this: I talked to Puzzle/hitobito, they unfortunately don't have capacity to look at this at the moment. I'll investigate if we can fork this under https://github.com/scout-ch

@openscript
Copy link

openscript commented Jul 2, 2024

Thank you @cleverer! I'm a new joiner and your pr was a massive help for setting up a devcontainer with working LSP across wagons!

I've combined it with the v2 branch: https://github.com/hitobito/development/tree/v2-devcontainer

@openscript
Copy link

I've migrated my branch to postgresql. I didn't need to change much. The work of @cleverer is still going strong.

@Largo
Copy link

Largo commented Oct 31, 2024

@cleverer
I think this is a good idea, however it would be good to dynamically generate the devcontainer.json files, or somehow change it that it only needs one. You could parse which wagons are available in the github repos.

Then also I would support your idea of putting a badge in the wagon repos to allow opening wagons inside a devcontainer. Thinking about this, most likely it would be easiest for this feature to put this into the wagon repositories directly, but considering that then we need to manage it there, maybe there is also a way to link from a devcontainer config inside the wagon to the full configuration in here.

@cleverer
Copy link
Contributor Author

@cleverer I think this is a good idea, however it would be good to dynamically generate the devcontainer.json files, or somehow change it that it only needs one. You could parse which wagons are available in the github repos.

Then also I would support your idea of putting a badge in the wagon repos to allow opening wagons inside a devcontainer. Thinking about this, most likely it would be easiest for this feature to put this into the wagon repositories directly, but considering that then we need to manage it there, maybe there is also a way to link from a devcontainer config inside the wagon to the full configuration in here.

Thank you for your for your inputs!

Upstream changed quite a lot of the setup, with new scripts etc. Also this PR actually already contains way too many changes. I would probably support splitting up all the changes into multiple smaller PRs, where we first only make sure to actually get the codespaces into the main branch and then can optimized with automated generation of the devcontainter configs.

I am not actively working with hitobito in my spare time and usually only did so at hackathons. So until the next Hackathon I will not touch this again.
At the next Hackathon I might start over from scratch, porting all the changes in this PR onto develop and adapting it to the new setup. But I might also do something completely different… so if anyone wants to take up this topic, feel free to do so and refer to this PR.

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.

4 participants