From 1bda023dfe8de3626be799fb6ca5bea550c01d48 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sat, 2 Nov 2019 16:28:52 +0800 Subject: [PATCH 1/4] add files for code and learn at COSCon 2019 --- archive/shanghai-2019/Dockerfile | 28 +++++++++++++++ archive/shanghai-2019/README.md | 4 +++ archive/shanghai-2019/preparation.md | 53 ++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 archive/shanghai-2019/Dockerfile create mode 100644 archive/shanghai-2019/README.md create mode 100644 archive/shanghai-2019/preparation.md diff --git a/archive/shanghai-2019/Dockerfile b/archive/shanghai-2019/Dockerfile new file mode 100644 index 0000000..9730a79 --- /dev/null +++ b/archive/shanghai-2019/Dockerfile @@ -0,0 +1,28 @@ +FROM ubuntu:bionic + +# Install tools +RUN apt-get update +RUN apt-get install -y build-essential python ninja-build make g++ vim git sudo + +# Expose ports used by net tests +ENV NODE_COMMON_PORT=12346 +EXPOSE 12346 +# debug port used by v8 debugger +EXPOSE 5858 +# debug port used by v8 insepctor +EXPOSE 9229 + +# Set up user node-dev: the tests fail when run by the root +RUN adduser --disabled-password --gecos '' node-dev +RUN adduser node-dev sudo +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +USER node-dev +WORKDIR /home/node-dev +ENV HOME /home/node-dev + +# Clone the code and build +git clone --depth=1 https://github.com/nodejs/node.git +WORKDIR /home/node-dev/node +RUN python2 ./configure --ninja +ENV BUILD_WITH ninja +make -j2 test diff --git a/archive/shanghai-2019/README.md b/archive/shanghai-2019/README.md new file mode 100644 index 0000000..e8d4809 --- /dev/null +++ b/archive/shanghai-2019/README.md @@ -0,0 +1,4 @@ +# Node.js Code + Learn @ COSCon 2019 + +- [事前准备(praparation)](./preparation.md) +- [Dockerfile](./Dockerfile) diff --git a/archive/shanghai-2019/preparation.md b/archive/shanghai-2019/preparation.md new file mode 100644 index 0000000..cefe32c --- /dev/null +++ b/archive/shanghai-2019/preparation.md @@ -0,0 +1,53 @@ +# 事前准备 + +## 安装环境 + +### MacOS + +1. 从 App Store 安装 Xcode +2. 从命令行运行 + + ``` + xcode-select --install + ``` +3. 推荐安装 ninja。如使用 homebrew: + + ``` + brew install ninja + ``` + +### Ubuntu + +``` +apt-get update +apt-get install -y build-essential python ninja-build make g++ +``` + +### 其他环境 + +UNIX: https://github.com/nodejs/node/blob/master/BUILDING.md#unix-prerequisites +Windows: https://github.com/nodejs/node/blob/master/BUILDING.md#prerequisites + +## 构建与测试 + +全部环境:推荐先 clone Node.js core 的代码。因为体积较大,建议用 `--depth=1`: + +``` +git clone --depth=1 https://github.com/nodejs/node.git +``` + +推荐在参加前先编译(需耗时半个小时到一个小时)和运行一遍测试(会从 npm 下载一些渲染 API 文档需要的包)。MacOS 和 Linux: + +``` +cd node + +# 如果有安装 ninja +python2 ./configure --ninja +BUILD_WITH=ninja make -j2 test + +# 如果没有安装 ninja +python2 ./configure +make -j2 test +``` + +其中 -j2 的 2 可以替换成机器上的 CPU 逻辑核心数。 From 879ec0a8ec80174f0b4cc8d88c0e08b7a067b6d2 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sat, 2 Nov 2019 16:38:17 +0800 Subject: [PATCH 2/4] fix dockerfile --- archive/shanghai-2019/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/archive/shanghai-2019/Dockerfile b/archive/shanghai-2019/Dockerfile index 9730a79..b275318 100644 --- a/archive/shanghai-2019/Dockerfile +++ b/archive/shanghai-2019/Dockerfile @@ -21,8 +21,8 @@ WORKDIR /home/node-dev ENV HOME /home/node-dev # Clone the code and build -git clone --depth=1 https://github.com/nodejs/node.git +RUN git clone --depth=1 https://github.com/nodejs/node.git WORKDIR /home/node-dev/node RUN python2 ./configure --ninja ENV BUILD_WITH ninja -make -j2 test +RUN make -j2 test From a33fb1f31f422f2747a0ff965cafe86e9f5994c8 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sat, 2 Nov 2019 16:40:14 +0800 Subject: [PATCH 3/4] add slides --- archive/shanghai-2019/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/archive/shanghai-2019/README.md b/archive/shanghai-2019/README.md index e8d4809..3d7c2b4 100644 --- a/archive/shanghai-2019/README.md +++ b/archive/shanghai-2019/README.md @@ -1,4 +1,5 @@ # Node.js Code + Learn @ COSCon 2019 -- [事前准备(praparation)](./preparation.md) +- [事前准备 (praparation)](./preparation.md) - [Dockerfile](./Dockerfile) +- [Slides](https://docs.google.com/presentation/d/1NluODLOelMFyui10jSLY8T4M0F444LaG7Ir5u_tfOGM/edit?usp=sharing) From 7ea7b30c7953fca6274c928bbece859959eb8bb8 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sat, 2 Nov 2019 17:10:38 +0800 Subject: [PATCH 4/4] remove g++ and make --- archive/shanghai-2019/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archive/shanghai-2019/Dockerfile b/archive/shanghai-2019/Dockerfile index b275318..a9410ab 100644 --- a/archive/shanghai-2019/Dockerfile +++ b/archive/shanghai-2019/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:bionic # Install tools RUN apt-get update -RUN apt-get install -y build-essential python ninja-build make g++ vim git sudo +RUN apt-get install -y build-essential python ninja-build vim git sudo # Expose ports used by net tests ENV NODE_COMMON_PORT=12346