Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,50 @@ RUN useradd --uid $USER_UID --gid $USER_GID --shell /bin/bash --create-home deve

# Install sudo first
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends sudo
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl git git-restore-mtime sudo xz-utils

# No Sudo Prompt - thanks Electron for this
RUN echo 'developer ALL=NOPASSWD: ALL' >> /etc/sudoers.d/developer
RUN echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep

ENV DEBIAN_FRONTEND=1
ENV PATH=/usr/lib/ccache:$PATH

# Copy scripts and make them executable by both root and developer
COPY --chown=root:developer --chmod=0755 ./scripts/ /home/developer/scripts/
RUN /home/developer/scripts/install.sh
RUN /home/developer/scripts/ccache.sh

USER developer
RUN /home/developer/scripts/clone.sh

# Installing Nix and Cachix
RUN curl -L "https://github.com/$(sed -nE 's#.*(cachix/install-nix-action)@([a-f0-9]+).*#\1/raw/\2#p' /home/developer/nodejs/node/.github/workflows/test-shared.yml)/install-nix.sh" | \
Copy link
Member

@joyeecheung joyeecheung Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a variable, so that we can have two nightly build workflows, one for shared builds and one for static ones, then users can easily choose different images when spinning a container? That'll be handy if say one day I need to reproduce a bug that only reproduces with shared builds, then I can just spin a container with the shared builds and build it quickly without compiling the entire V8 and whatnot when I am working on non-Linux.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 885db6b...a8c190f. I've set the default value to false, to be consistent with the current images, though that's taking much longer to build

USER=developer \
INPUT_SET_AS_TRUSTED_USER=true \
INPUT_ENABLE_KVM=true \
INPUT_EXTRA_NIX_CONFIG= \
INPUT_INSTALL_OPTIONS= \
RUNNER_TEMP=$(mktemp -d) GITHUB_ENV=/dev/null GITHUB_PATH=/dev/null bash
ENV NIX_PROFILES="/nix/var/nix/profiles/default /home/developer/.nix-profile"
ENV NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
ENV PATH="/home/developer/.local/bin:/home/developer/.nix-profile/bin:${PATH}"
RUN nix-env -iA cachix -f https://cachix.org/api/v1/install
RUN USER=developer cachix use nodejs

# Installing direnv
RUN nix profile add nixpkgs#nix-direnv nixpkgs#direnv -I nixpkgs=/home/developer/nodejs/node/tools/nix/pkgs.nix
RUN mkdir -p /home/developer/.config/direnv && \
echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' > /home/developer/.config/direnv/direnvrc
RUN echo 'eval "$(direnv hook bash)"' >> /home/developer/.bashrc

# Setting up direnv for the local clone
ARG USE_SHARED_LIBS=false
RUN echo "use nix --impure -I nixpkgs=/home/developer/nodejs/node/tools/nix/pkgs.nix$([ "${USE_SHARED_LIBS}" = "true" ] || echo " --arg sharedLibDeps '{}' --argstr icu full")" > /home/developer/nodejs/node/.envrc
RUN direnv allow /home/developer/nodejs/node

RUN /home/developer/scripts/build.sh

ENV PATH=/home/developer/.local/bin:$PATH
WORKDIR /home/developer/nodejs/node
RUN /home/developer/scripts/install-node.sh
RUN /home/developer/scripts/ncu.sh

# direnv will automatically load the nix environment when entering the directory
ENTRYPOINT ["/bin/bash", "-l"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Do this from your local system, not in the container. The `git` configuration wi
Some useful commands:
- `docker build .` - build the current Dockerfile
- `docker image ls` - list the images and IDs
- `docker run -it <image id> /bin/bash` - run a container and shell into it
- `docker run -it <image id>` - run a container and shell into it
- `docker tag <image id> devcontainer:nightly` - run to tag an image as `nightly`


Expand Down
7 changes: 5 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

set -e # Exit with nonzero exit code if anything fails
set -xe

/home/developer/nodejs/node/configure --ninja && make -C /home/developer/nodejs/node
cd /home/developer/nodejs/node
eval "$(direnv export bash)"

make -C /home/developer/nodejs/node build-ci
Copy link
Member

@joyeecheung joyeecheung Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it have to use make? I think maybe it's about time that we can just use ninja in the GHA...it would be rather unfortunate to revert to make for development when the devcontainer is used, as it's not really pleasant to use for local development, and if the image is not built with ninja, then switching to ninja for development no longer hits the cache and everything has to be recompiled.

Copy link
Author

@aduh95 aduh95 Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The image is still using Ninja, it's defined in https://github.com/nodejs/node/blob/83ba6b107a067f5831b03ab69c787fcb35bdcb05/shell.nix#L87. The fact that the build is started with make predates this PR, the actual change in this PR is to use build-ci which calls ./configure then make all (defined in https://github.com/nodejs/node/blob/83ba6b107a067f5831b03ab69c787fcb35bdcb05/Makefile#L627-L629).

FWIW that's also what test-shared is doing on nodejs/node, and as you can see in e.g. https://github.com/nodejs/node/actions/runs/20067281194/job/57559349798, we're using Ninja there.

6 changes: 0 additions & 6 deletions scripts/ccache.sh

This file was deleted.

13 changes: 7 additions & 6 deletions scripts/clone.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env bash

set -e # Exit with nonzero exit code if anything fails
set -xe

mkdir -p /home/developer/nodejs
cd /home/developer/nodejs
git clone https://github.com/nodejs/node.git --single-branch --branch main --depth 1
cd /home/developer/nodejs/node
git remote add upstream https://github.com/nodejs/node.git
git restore-mtime # Restore file modification times to commit times for build cache to match.
git clone https://github.com/nodejs/node.git --depth 1 /home/developer/nodejs/node
(
cd /home/developer/nodejs/node
git remote add upstream https://github.com/nodejs/node.git
git restore-mtime # Restore file modification times to commit times for build cache to match.
)
12 changes: 9 additions & 3 deletions scripts/install-node.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/usr/bin/env bash

set -e # Exit with nonzero exit code if anything fails
set -xe

cd /home/developer/nodejs/node
eval "$(direnv export bash)"

make install PREFIX=/home/developer/.local -C /home/developer/nodejs/node
echo '' >> /home/developer/.bashrc
echo 'export PATH=/home/developer/.local/bin:$PATH' >> /home/developer/.bashrc
{
echo ''
# Expose the PATH generated by Nix + the recently built `node` installation
echo "export PATH=/home/developer/.local/bin:$PATH"
} >> /home/developer/.bashrc
35 changes: 0 additions & 35 deletions scripts/install.sh

This file was deleted.

5 changes: 3 additions & 2 deletions scripts/ncu.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash

set -e # Exit with nonzero exit code if anything fails
set -xe

npm install -g @node-core/utils
cd /home/developer/nodejs/node
eval "$(direnv export bash)"

ncu-config set upstream upstream
ncu-config set branch main
10 changes: 0 additions & 10 deletions scripts/setup-origin.sh

This file was deleted.