-
Notifications
You must be signed in to change notification settings - Fork 62
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 #911
base: main
Are you sure you want to change the base?
Add devcontainer #911
Conversation
What's required between merging this, and getting Github Codespaces/CodeSandbox working? If this is purely for local development, this seems to just overcomplicate things. I agree it's worth being explicit about minimum Node version and resolving the issue with That being said, I'm happy to work towards a fully remote setup. My question is, why do we need to merge this into main to keep working on the Codespaces stuff? Is it not possible to do the same work off of your fork? I'm a little wary of merging something relatively useless only just as a stepping stone for future PRs. On one hand there's not much harm in merging this now, and if you end up disappearing (not saying you will, be it's unfortunately quite common with devs on this project) I could just remove it. One the other hand, the multi-container Codespaces stuff sounds a little dicey, and I worry that merging this now may make it harder to just cut our losses and give up with it in the future, or it may end up snowballs into a huge time-sink for you. Not that I don't greatly appreciate this work by the way, increasing accessibility for new devs is hugely important for us and this shows a lot of promise! I just want to get a clear picture of what the path forward for this is before merging. |
I think there's not a lot left to get codespaces working with this, just need to go through these docs and try it out myself and add a few scripts from there to the devcontainer setup. I'm fine continuing that before we consider merging this. I can certainly work off my fork for that. The big draw of using a devcontainer locally for me is that I don't need to install any dependencies on my local system beyond docker and vs code. So if I work on multiple node projects at the same time that have different version requirements or conflicting ports I don't have to remember to switch back and forth. The number of global dependencies for this project is pretty low (node and nx right now) but running the entire project in a container eliminates the need for these entirely and ensures devs are on exactly the same version so we have a consistent and reproducible dev environment. Granted, I can keep using this myself without having it checked into the repo, but I figured it could also be a useful option for other devs as is. For now I'll plan to add codespaces stuff to this PR though. |
Yeah providing a local container-only approach is reasonable, but wouldn't it be easier just dockerizing that entire process, rather than using devcontainers? I don't really know anything about devcontainers whatsoever, but keeping the number of dev technologies to a minimum is preferable, so I'd rather only offer devcontainers as an option if it can replace an existing requirement (e.g. Docker) |
At their core, devcontainers are just a small editor config on top of the existing docker-compose stack that provides some metadata to your editor about which container in the compose stack to attach to, what plugins to install to the editor, what ports to forward, etc. I opted to forward ports for example to avoid extra changes in this PR. Forwarded ports use an editor feature to make traffic appear to the container as if it came from localhost. We could instead modify the API process to listen on |
Okay, that makes a lot of sense. And sorry, I've been so busy with other stuff lately I didn't sit down and look at devcontainers at all until just now. Glad that it's an open spec, and like you say they're just configurations for editors to follow, which is certainly helpful as a way to avoid getting hands dirty w Docker directly, having to choose what containers to attach to via CLI etc. |
Heads up that we don't accept merge commits, please rebase! |
We already encourage users to use docker to spin up containers for minio and postgres so I figured it could be useful to extend these configs such that devs are able to spin up the entire development environment in docker. This is completely optional, but hopefully this can help newer devs onboard more quickly and avoid compatibility issues (for example incorrect node versions).
This config can also be utilized as a basis for running the project in places like CodeSandbox and GitHub Codespaces, which can sometimes be useful for sharing local builds, quickly spinning up branches and PRs in an env for testing, or developing on hardware like tablets where you might only have access to a browser. Since we utilize multiple containers, some extra steps found here are needed.
Setup steps for the repo when running in a devcontainer on your local machine:
F1
) and selectMomentum Mod API
.env
and add yourSTEAM_WEB_API_KEY
as described hereF1
) and run Rebuild ContainerNest application successfully started
log in the output, open a new VS Code window using File > New Window and open the project root in that new windowF1
) and selectMomentum Mod Website
Local: http://localhost:4200/
and open that address in your browser and you should see the Momentum Mod website. You should now have everything you need to contribute!Once this is merged into main, we can use the following link instead of steps 2-5:
https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/momentum-mod/website This automatically installs the Dev Containers extension, clones the repo, and opens the project in the container.
Other editors with Dev Container support can be used instead of VS Code can be used although I haven't tested these. See the list of supported editors here
Troubleshooting:
F1
) and run Rebuild Containerdocker compose down