├── .github └── workflows │ └── docker-build-and-publish.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── Dockerfile ├── LICENSE ├── README.md ├── TODO.md └── scripts ├── build.sh ├── ccache.sh ├── clone.sh ├── install.sh ├── mkdir.sh ├── ncu.sh └── setup-origin.sh /.github/workflows/docker-build-and-publish.yml: -------------------------------------------------------------------------------- 1 | name: Build and Publish Image 2 | 3 | on: 4 | workflow_dispatch: # allows us to trigger runs manually in the GitHub UI 5 | schedule: 6 | - cron: '0 0 * * *' # runs nightly 7 | 8 | jobs: 9 | docker: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Set up QEMU 13 | uses: docker/setup-qemu-action@v1 14 | - name: Set up Docker Buildx 15 | uses: docker/setup-buildx-action@v1 16 | - name: Login to DockerHub 17 | uses: docker/login-action@v1 18 | with: # these are defined in the GitHub Secrets UI 19 | username: ${{ secrets.DOCKERHUB_USERNAME }} 20 | password: ${{ secrets.DOCKERHUB_TOKEN }} 21 | - name: Build and push 22 | id: docker_build 23 | uses: docker/build-push-action@v2 24 | with: 25 | push: true 26 | tags: nodejs/devcontainer:nightly 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Microbundle cache 58 | .rpt2_cache/ 59 | .rts2_cache_cjs/ 60 | .rts2_cache_es/ 61 | .rts2_cache_umd/ 62 | 63 | # Optional REPL history 64 | .node_repl_history 65 | 66 | # Output of 'npm pack' 67 | *.tgz 68 | 69 | # Yarn Integrity file 70 | .yarn-integrity 71 | 72 | # dotenv environment variables file 73 | .env 74 | .env.test 75 | .env.production 76 | 77 | # parcel-bundler cache (https://parceljs.org/) 78 | .cache 79 | .parcel-cache 80 | 81 | # Next.js build output 82 | .next 83 | out 84 | 85 | # Nuxt.js build / generate output 86 | .nuxt 87 | dist 88 | 89 | # Gatsby files 90 | .cache/ 91 | # Comment in the public line in if your project uses Gatsby and not Next.js 92 | # https://nextjs.org/blog/next-9-1#public-directory-support 93 | # public 94 | 95 | # vuepress build output 96 | .vuepress/dist 97 | 98 | # Serverless directories 99 | .serverless/ 100 | 101 | # FuseBox cache 102 | .fusebox/ 103 | 104 | # DynamoDB Local files 105 | .dynamodb/ 106 | 107 | # TernJS port file 108 | .tern-port 109 | 110 | # Stores VSCode versions used for testing VSCode extensions 111 | .vscode-test 112 | 113 | # yarn v2 114 | .yarn/cache 115 | .yarn/unplugged 116 | .yarn/build-state.yml 117 | .yarn/install-state.gz 118 | .pnp.* 119 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributor Covenant Code of Conduct 3 | 4 | ## Our Pledge 5 | 6 | We as members, contributors, and leaders pledge to make participation in our 7 | community a harassment-free experience for everyone, regardless of age, body 8 | size, visible or invisible disability, ethnicity, sex characteristics, gender 9 | identity and expression, level of experience, education, socio-economic status, 10 | nationality, personal appearance, race, caste, color, religion, or sexual identity 11 | and orientation. 12 | 13 | We pledge to act and interact in ways that contribute to an open, welcoming, 14 | diverse, inclusive, and healthy community. 15 | 16 | ## Our Standards 17 | 18 | Examples of behavior that contributes to a positive environment for our 19 | community include: 20 | 21 | * Demonstrating empathy and kindness toward other people 22 | * Being respectful of differing opinions, viewpoints, and experiences 23 | * Giving and gracefully accepting constructive feedback 24 | * Accepting responsibility and apologizing to those affected by our mistakes, 25 | and learning from the experience 26 | * Focusing on what is best not just for us as individuals, but for the 27 | overall community 28 | 29 | Examples of unacceptable behavior include: 30 | 31 | * The use of sexualized language or imagery, and sexual attention or 32 | advances of any kind 33 | * Trolling, insulting or derogatory comments, and personal or political attacks 34 | * Public or private harassment 35 | * Publishing others' private information, such as a physical or email 36 | address, without their explicit permission 37 | * Other conduct which could reasonably be considered inappropriate in a 38 | professional setting 39 | 40 | ## Enforcement Responsibilities 41 | 42 | Community leaders are responsible for clarifying and enforcing our standards of 43 | acceptable behavior and will take appropriate and fair corrective action in 44 | response to any behavior that they deem inappropriate, threatening, offensive, 45 | or harmful. 46 | 47 | Community leaders have the right and responsibility to remove, edit, or reject 48 | comments, commits, code, wiki edits, issues, and other contributions that are 49 | not aligned to this Code of Conduct, and will communicate reasons for moderation 50 | decisions when appropriate. 51 | 52 | ## Scope 53 | 54 | This Code of Conduct applies within all community spaces, and also applies when 55 | an individual is officially representing the community in public spaces. 56 | Examples of representing our community include using an official e-mail address, 57 | posting via an official social media account, or acting as an appointed 58 | representative at an online or offline event. 59 | 60 | ## Enforcement 61 | 62 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 63 | reported to the community leaders responsible for enforcement at 64 | hello@bnb.im. 65 | All complaints will be reviewed and investigated promptly and fairly. 66 | 67 | All community leaders are obligated to respect the privacy and security of the 68 | reporter of any incident. 69 | 70 | ## Enforcement Guidelines 71 | 72 | Community leaders will follow these Community Impact Guidelines in determining 73 | the consequences for any action they deem in violation of this Code of Conduct: 74 | 75 | ### 1. Correction 76 | 77 | **Community Impact**: Use of inappropriate language or other behavior deemed 78 | unprofessional or unwelcome in the community. 79 | 80 | **Consequence**: A private, written warning from community leaders, providing 81 | clarity around the nature of the violation and an explanation of why the 82 | behavior was inappropriate. A public apology may be requested. 83 | 84 | ### 2. Warning 85 | 86 | **Community Impact**: A violation through a single incident or series 87 | of actions. 88 | 89 | **Consequence**: A warning with consequences for continued behavior. No 90 | interaction with the people involved, including unsolicited interaction with 91 | those enforcing the Code of Conduct, for a specified period of time. This 92 | includes avoiding interactions in community spaces as well as external channels 93 | like social media. Violating these terms may lead to a temporary or 94 | permanent ban. 95 | 96 | ### 3. Temporary Ban 97 | 98 | **Community Impact**: A serious violation of community standards, including 99 | sustained inappropriate behavior. 100 | 101 | **Consequence**: A temporary ban from any sort of interaction or public 102 | communication with the community for a specified period of time. No public or 103 | private interaction with the people involved, including unsolicited interaction 104 | with those enforcing the Code of Conduct, is allowed during this period. 105 | Violating these terms may lead to a permanent ban. 106 | 107 | ### 4. Permanent Ban 108 | 109 | **Community Impact**: Demonstrating a pattern of violation of community 110 | standards, including sustained inappropriate behavior, harassment of an 111 | individual, or aggression toward or disparagement of classes of individuals. 112 | 113 | **Consequence**: A permanent ban from any sort of public interaction within 114 | the community. 115 | 116 | ## Attribution 117 | 118 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 119 | version 2.1, available at 120 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 121 | 122 | Community Impact Guidelines were inspired by 123 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 124 | 125 | For answers to common questions about this code of conduct, see the FAQ at 126 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available 127 | at [https://www.contributor-covenant.org/translations][translations]. 128 | 129 | [homepage]: https://www.contributor-covenant.org 130 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 131 | [Mozilla CoC]: https://github.com/mozilla/diversity 132 | [FAQ]: https://www.contributor-covenant.org/faq 133 | [translations]: https://www.contributor-covenant.org/translations 134 | 135 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest AS build 2 | 3 | RUN groupadd --gid 1000 developer \ 4 | && useradd --uid 1000 --gid developer --shell /bin/bash --create-home developer 5 | 6 | ENV DEBIAN_FRONTEND=1 7 | ENV PATH /usr/lib/ccache:$PATH 8 | 9 | COPY --chown=root:developer ./scripts/ /home/developer/scripts/ 10 | RUN /home/developer/scripts/install.sh && /home/developer/scripts/mkdir.sh && /home/developer/scripts/ccache.sh && /home/developer/scripts/clone.sh && /home/developer/scripts/build.sh && make install -C /home/developer/nodejs/node && /home/developer/scripts/ncu.sh 11 | 12 | WORKDIR /home/developer/nodejs/node 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License Copyright (c) 2021 Tierney Cyren 2 | 3 | Permission is hereby granted, free 4 | of charge, to any person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to the 9 | following conditions: 10 | 11 | The above copyright notice and this permission notice 12 | (including the next paragraph) shall be included in all copies or substantial 13 | portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO 18 | EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Node.js Developer Container (`devcontainer`) 2 | 3 | ## Usage 4 | 5 | ### Setup 6 | 7 | #### Running with Docker Desktop 8 | 9 | To run locally on your machine, you'll want to install [Docker Desktop](https://www.docker.com/products/docker-desktop/) and start it up. 10 | 11 | Once you've got Docker Destop running, you can run the following command to pull and start the image: 12 | 13 | ```sh 14 | docker pull nodejs/devcontainer:nightly 15 | docker run -it nodejs/devcontainer:nightly /bin/bash 16 | ``` 17 | 18 | Once you've run those commands, you'll be in a shell inside the running container. If you need to escape, type `exit`. You should be good to jump to [Working in the Container](#working-in-the-container). 19 | 20 | ### Working in the Container 21 | 22 | - The project is located at `/home/developer/nodejs/node`. 23 | - Once this directory is your active directory, you should be good to go. 24 | - If you want to build the project in the container, run with ninja (rather than just make): 25 | - `/home/developer/nodejs/node/configure --ninja && make -C /home/developer/nodejs/node` 26 | - You should be able to attach any editor that supports the concept of [`devcontainers`](https://containers.dev/) to this 27 | 28 | ### Personal Configuration 29 | 30 | Assuming you've already got the Docker container running: 31 | 32 | - Set the git `origin` to your own fork rather than `nodejs/node` 33 | - Example, where `USERNAME` is your GitHub username: `$ git remote set-url origin https://github.com/USERNAME/node.git` 34 | - Verify the remote is valid: `git remote -v` 35 | - Set up your git name and email 36 | - `git config --global user.name "YOUR NAME"` 37 | - `git config --global user.email "YOUR@EMAIL.TLD"` 38 | - Add your SSH key 39 | - Preferably one that's already [published to GitHub](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) 40 | - Alternatively, you can install the [`gh` CLI](https://cli.github.com/) and run `gh auth login` to login and add a new key. 41 | 42 | ## Development 43 | 44 | Some useful commands: 45 | - `docker build .` - build the current Dockerfile 46 | - `docker image ls` - list the images and IDs 47 | - `docker run -it /bin/bash` - run a container and shell into it 48 | - `docker tag devcontainer:nightly` - run to tag an image as `nightly` 49 | 50 | 51 | ### Tips and Tricks for Debugging Failed Builds and Otherwise Developing in This Repo 52 | 53 | Some notes on what's been helpful: 54 | 55 | - Break up the `RUN` statement in the [Dockerfile][] into multiple `RUN` statements, each containing a single command. This provies more precise information about what exactly is failing if the Docker build fails and isn't providing helpful output. 56 | - Sometimes removing the `RUN` statement in the [Dockerfile][] and running `docker build`, running the built container, and individually running each command in the running container is a better development experience than working outside of the built container. 57 | 58 | [Dockerfile]: ./Dockerfile 59 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | - [x] Switch to `node:latest` 2 | - [x] Install `node-core-utils` 3 | - [x] Documentation -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e # Exit with nonzero exit code if anything fails 4 | 5 | /home/developer/nodejs/node/configure --ninja && make -C /home/developer/nodejs/node 6 | -------------------------------------------------------------------------------- /scripts/ccache.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e # Exit with nonzero exit code if anything fails 4 | 5 | # create symlinks 6 | /usr/sbin/update-ccache-symlinks 7 | -------------------------------------------------------------------------------- /scripts/clone.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e # Exit with nonzero exit code if anything fails 4 | 5 | cd /home/developer/nodejs 6 | git clone https://github.com/nodejs/node.git --single-branch --branch main --depth 1 7 | cd /home/developer/nodejs/node 8 | git remote add upstream https://github.com/nodejs/node.git 9 | git fetch upstream 10 | -------------------------------------------------------------------------------- /scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e # Exit with nonzero exit code if anything fails 4 | 5 | package_list=" 6 | build-essential \ 7 | ccache \ 8 | curl \ 9 | nano \ 10 | python3 \ 11 | python-setuptools \ 12 | python3-pip \ 13 | ninja-build \ 14 | g++ \ 15 | sudo \ 16 | make \ 17 | git \ 18 | locales \ 19 | gpg \ 20 | wget" 21 | 22 | # Install Packages 23 | apt-get update 24 | DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $package_list 25 | 26 | # set up GitHub CLI resistry stuff to get gh CLI 27 | curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg 28 | echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null 29 | gh_package_list="gh" 30 | apt-get update 31 | DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $gh_package_list 32 | 33 | # No Sudo Prompt - thanks Electron for this 34 | echo 'developer ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-developer 35 | echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep 36 | -------------------------------------------------------------------------------- /scripts/mkdir.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e # Exit with nonzero exit code if anything fails 4 | 5 | mkdir /home/developer/nodejs 6 | mkdir -p /home/developer/ninja/out/Release 7 | -------------------------------------------------------------------------------- /scripts/ncu.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e # Exit with nonzero exit code if anything fails 4 | 5 | npm install -g node-core-utils 6 | 7 | ncu-config set upstream upstream 8 | ncu-config set branch main 9 | -------------------------------------------------------------------------------- /scripts/setup-origin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e # Exit with nonzero exit code if anything fails 4 | 5 | if [[ -z "${ORIGIN_URL}" ]] 6 | then 7 | echo "ORIGIN_URL is not set" 8 | else 9 | git remote set-url origin ${ORIGIN_URL} 10 | fi 11 | --------------------------------------------------------------------------------