feat(devcontainers): add the ability to use GitHub Codespaces and VS Code remote containers (#5631)

This commit is contained in:
Andrew Brey
2023-10-22 03:13:26 -07:00
committed by GitHub
parent c6d3fa61ef
commit 26ab4e6d4b
5 changed files with 46 additions and 0 deletions

11
.devcontainer/Dockerfile Normal file
View File

@@ -0,0 +1,11 @@
ARG NODE_MAJOR_VERSION
FROM mcr.microsoft.com/devcontainers/javascript-node:${NODE_MAJOR_VERSION}
ENV EDITOR="code -w" VISUAL="code -w"
# install system dependencies for cypress (https://docs.cypress.io/guides/continuous-integration/introduction)
RUN apt update && apt install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6 xauth xvfb
# uncomment to install additional npm packages
# RUN su node -c 'npm i -g cowsay@1.5.0'

View File

@@ -0,0 +1,16 @@
{
"name": "compiler-explorer",
"dockerFile": "Dockerfile",
"build": {
"args": {"NODE_MAJOR_VERSION": "20"}
},
"postCreateCommand": [".devcontainer/post-create.sh"],
"portsAttributes": {
"10240": {"label": "Compiler Explorer"}
},
"customizations": {
"vscode": {
"extensions": ["dbaeumer.vscode-eslint", "EditorConfig.EditorConfig", "esbenp.prettier-vscode"]
}
}
}

14
.devcontainer/post-create.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -eo pipefail
# when in a VS Code or GitHub Codespaces devcontainer
if [ -n "${REMOTE_CONTAINERS}" ]; then
this_dir=$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)
workspace_root=$(realpath ${this_dir}/..)
# perform additional one-time setup just after
# the devcontainer is created
npm install --prefix "${workspace_root}" # install node dependencies
fi

View File

@@ -23,6 +23,10 @@ in the right direction.
**Compiler Explorer** currently targets [Node.js](https://nodejs.org/) version 20, so it's better if you do so as well
when testing your changes locally.
> Note that this repository is compatible with `GitHub Codespaces` as well as `VS Code Dev Containers`. Opening your
> cloned project with either of these options will ensure that your development environment is already set up and
> configured correctly!
## In brief
- Make your changes, trying to stick to the style and format where possible.

View File

@@ -139,3 +139,4 @@ From oldest to newest contributor, we would like to thank:
- [Seyed Ali Ghasemi](https://github.com/gha3mi)
- [Guo Ci](https://github.com/guoci)
- [Rupert Tombs](https://github.com/Rupt)
- [Andrew Brey](https://github.com/andrewbrey)