Add: devcontainer to make development easier #230
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So this requires a bit of story.
tldr; this is PR is to test the waters, to see if we like this approach, and if the benefits of "anyone can jump in" outweigh the "but there are IDE-specific things in the repo".
But if you want to pitch in, I really urge you to read what I write below :)
For a while now I notice that there are people who have the best intentions to help out with things like our website, but also bananas-server, master-server-web, game-coordinator, etc. But mainly they get stuck in how to setup the development environment.
It is not that the environments themselves are complex, but each repository has its own required setup to work. Take for example game-coordinator, it requires a redis to run, but it is also composed of three applications: coordinator, stun and turn. These all three needs a bit of configuration. Nothing that is not documented, but to "just jump in and develop" is not the case.
I even notice that myself. This week frosch mentioned that a bug in master-server is most likely easily solved by changing a
set
into aset(nx=True)
. But to test this, it takes me time to setup the right environment and validate that. As it is a really minor thing, I postpone this. (read: I cannot just jump in)For BaNaNaS related repository, we have had several people just give up because they couldn't follow the README. Now we can argue that the README is not clear and should be updated, but really .. it contains everything you need. It is just "a lot" if you never worked with it. In the BaNaNaS case specifically, you kinda want some dummy files to play around with .. and that is just difficult to get done on a moments notice.
So, I have been wondering what "devcontainers" is all about. GitHub claims it solves all those problems, so I gave it a spin with this repository (this repository is not the most complicated we have, but also not the easiest). Basically devcontainers can be used in two ways:
The idea behind devcontainers is that it contains everything you need to get a working setup. Including databases, storages, ... Additionally, it helps you as much as possible to just "jump in". But, one drawback, it is strongly biased towards the use of VSCode. It is slowly being made a bit more broad, but I have no illusions it will always remain VSCode-ish. For example, only since recent it is easier to ssh into Codespaces to use
emacs
orvim
to develop with. And I couldn't find any other editor that implements devcontainers (I love to be proven wrong here!).More details about devcontainers, and what they are about, can be found here.
Either way, this is PR is to test the waters, to see if we like this approach, and if the benefits of "anyone can jump in" outweigh the "but there are IDE-specific things in the repo".
If you are signed up for GitHub Codespaces, you can press the green "Code" button on https://github.com/TrueBrain/OpenTTD-website and hit "New codespace".
Within a minute or-so you are in VSCode ready to edit the website. Via F1 -> Run Tasks -> Start server, you can start the server. A popup will ask you to open a tab to see the website. And that makes writing blog-posts etc a lot easier, as you can see how the layout will be. But it also allows for easier CSS changes, validating of PRs, etc etc. And .. you can do it from anywhere you like ;)
If you don't want to use Codespaces, you can use VSCode Remote Containers extension. After installing the extension you can go to F1 -> Remote-Containers: Clone Repository in Container Volume. Fill in https://github.com/TrueBrain/OpenTTD-website and off you go. A few minutes later (assuming you have Docker installed) you can edit the website exactly as described above.
(and before anyone asks, after merging these PR, the above URLs of course changes into this repository; but I pushed it to my fork so you can try it out!)
If this idea works, and we like this approach, I want to try to do bananas-server next. This also requires a working OpenTTD game to communicate with the bananas-server for testing (next to checking out some dummy BaNaNaS files etc). I am considering using Emscripten for this, so it works from your browser. This hopefully makes it really trivial to try things out with Codespaces.
For the VSCode Remote Containers route, you can just start OpenTTD with
OTTD_CONTENT_CS="localhost"
, to test against.Either way .. if it is up to me, this is the first of many of very similar PRs to make our development environments a lot easier for anyone to work with .. to just "jump in and develop". Hopefully that attracts more developers to help out.
Let me know what you think, please try it out (make sure to signup for Codespaces ;)), and if you have any improvements / suggestions, I am all ears!