Skip to content
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

Pipeline and scripts for custom node 18 build (with glibc 2.17) #4

Merged
merged 76 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
ddddc28
feat: add scripts for building custom node distributions
delanni Jun 6, 2023
7e1ef7a
feat: add pipeline definition for the build
delanni Jun 7, 2023
b1fc304
feat: fix typos
delanni Jun 7, 2023
36f5f9f
feat: try fixing 'privileged mode is incompatible with user namespace…
delanni Jun 7, 2023
4dd173c
try without qemu
delanni Jun 7, 2023
260f10c
try creating a driver instead
delanni Jun 7, 2023
84e6a42
feat: remove --force flag
delanni Jun 7, 2023
8f86ed5
feat: increase timeouts and add wait between stages
delanni Jun 7, 2023
545d8d1
feat: fix bad param name in build script
delanni Jun 7, 2023
2104c0c
feat: push/pull images to docker.io/elastic
delanni Jun 8, 2023
d0ac37f
feat: use new images, branch in build script based on ARCH env variable
delanni Jun 8, 2023
3cca249
Try manual login/build/upload to elastic's docker repo
delanni Jun 9, 2023
5ac745d
add agent definition
delanni Jun 9, 2023
ef3d7bc
Load docker image before progressing to next step
delanni Jun 12, 2023
07a3796
Try building in the same step
delanni Jun 12, 2023
f375c10
List images, to see why they're not available
delanni Jun 12, 2023
10c26eb
Fix arm-amd mixup
delanni Jun 12, 2023
4859c07
Add +x flag to entrypoint scripts
delanni Jun 12, 2023
4e53748
List dirs, wonder why they're not accessible
delanni Jun 12, 2023
17acf35
Add Z flag, to access the directories
delanni Jun 12, 2023
4583258
Increase timeout, try build in different steps
delanni Jun 12, 2023
b45822e
Separate builds because 'ERROR: docker exporter does not currently su…
delanni Jun 12, 2023
15e9c59
Fix bad image names and conditionals
delanni Jun 12, 2023
43d3007
Try arm64 build
delanni Jun 13, 2023
1e0e916
use arm machines for arm build
delanni Jun 14, 2023
046ef03
Add a pre-checkout hook to try to fix github urls
delanni Jun 14, 2023
5d3db88
Add a few commands for discovery
delanni Jun 14, 2023
6e887aa
Add post-checkout hook to cleanup git configs
delanni Jun 14, 2023
a3c45fa
No post-checkout - it changes the kibana executors for good, might me…
delanni Jun 14, 2023
a7bac4e
Refactor, and prepare pipeline for upload
delanni Jun 14, 2023
7a08d5d
Retry after fixing access rights
delanni Jun 14, 2023
c3dd54d
Strip -glibc-217 variant from filenames to keep original naming
delanni Jun 14, 2023
c63603b
Plug in ARM build, try a complete build
delanni Jun 14, 2023
fa10326
Attempt build on the macos executor
delanni Jun 15, 2023
9b0d9f9
Retreat back to cross-compiling, while the agent is set up
delanni Jun 15, 2023
a20eefc
Fix arm64<->amd64 parameterization, names
delanni Jun 19, 2023
000e638
Allow all users to rwx on created artifacts, so external scripts can …
delanni Jun 19, 2023
805e765
Allow writing of the created dist folder, to allow for rename
delanni Jun 19, 2023
d3e6284
Try macos executor again
delanni Jun 20, 2023
75354d2
Re-add x64 build
delanni Jun 20, 2023
6b71765
Bump to build node 18.16.0
delanni Jun 20, 2023
3eb5955
Find where the node builds are running, for debugging
delanni Jun 20, 2023
2e589f5
More debug
delanni Jun 20, 2023
3eb345d
Try fast agents with cross-compilation
delanni Jun 20, 2023
b9916d1
Try building re2
delanni Jun 21, 2023
2785d83
Mkdir & new folder names to avoid clash
delanni Jun 21, 2023
c037b40
Fix docker image name
delanni Jun 21, 2023
133ccff
Centralize build image name, so there are no typos
delanni Jun 21, 2023
1813dec
Fix double slash typo in path
delanni Jun 21, 2023
922dec3
Use public URLs for the node distro
delanni Jun 21, 2023
42b4990
Use npm binary extracted locally
delanni Jun 21, 2023
c13eb22
Remove variant from extracted node folder if needed
delanni Jun 21, 2023
07f47df
Add SHA256 file fixing,remove variation, fix re2 artifact building
delanni Jun 21, 2023
edd9232
Re-add upload section
delanni Jun 22, 2023
bdd64e8
Use correct path for SHASUMS256.txt
delanni Jun 22, 2023
7a61c2e
Use spaces in shasum file, re-enable mac build, bump node version
delanni Jun 22, 2023
702ca66
Add SHASUM fixing as a last step after both agents finished
delanni Jun 22, 2023
58f0c0a
Add retry around node download.. node.js org is flaky
delanni Jun 22, 2023
e85ade7
Fix typo, temporarily disable build steps
delanni Jun 22, 2023
7dde65d
Re-enable build steps
delanni Jun 22, 2023
fecc714
Remove unnecessary files, add README/Context
delanni Jun 22, 2023
a05224f
Merge branch 'main' into docker-manual-upload
delanni Jun 22, 2023
1656a11
Update README.md
delanni Jun 23, 2023
21f14c0
Centralize the artifacts' upload bucket name
delanni Jun 26, 2023
68d258e
Remove RE2 aspects of the build
delanni Jun 27, 2023
ab58662
Remove traces of the ci-systems pipeline
delanni Jun 27, 2023
9957258
Rationalize timeouts for beefier runner instances
delanni Jun 27, 2023
12ed8d8
Rename pipeline-kibana to pipeline, as the default
delanni Jun 27, 2023
00a8b2f
Update .buildkite/pipeline.yml
delanni Jun 29, 2023
8997a62
Update .buildkite/pipeline.yml
delanni Jun 29, 2023
983da3e
try overriding node target version in command
delanni Jun 29, 2023
c18809e
Fix default value expression
delanni Jun 29, 2023
8e0ae33
Remove debug / exit statements
delanni Jun 29, 2023
5c1d41e
Centralize version override, add annotation for built version
delanni Jun 29, 2023
8c34500
Fix typo for --style
delanni Jun 29, 2023
7ce4d9b
Fix defaulting logic
delanni Jun 29, 2023
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
49 changes: 35 additions & 14 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
agents:
provider: aws
instanceType: m6g.xlarge
imagePrefix: drivah-ubuntu-2204-aarch64
env:
TARGET_VERSION: 18.16.1
mistic marked this conversation as resolved.
Show resolved Hide resolved

steps:
- label: ":buildah: Building Container Images for ARM64"
branches: "*"
command: |
buildah --version
drivah build --changed-since=main ./containers/arm64
- label: Annotate build with node version
command: buildkite-agent annotate "node.js v$${OVERRIDE_TARGET_VERSION:-$$TARGET_VERSION} with glibc 2.17" --style 'info'
agents:
queue: kibana-default

# - label: ":buildah: Building Container Images for AMD64"
# branches: "*"
# command: |
# buildah --version
# drivah build --changed-since=main ./.buildkite/containers/amd64
- label: Build custom node.js artifacts with glibc 2.17 for x64
command:
- scripts/create_build_images.sh
- scripts/build_nodejs.sh
- scripts/upload_nodejs_artifacts.sh
env:
ARCH: amd64
agents:
queue: c2-16
timeout_in_minutes: 60 # ideally runs in ~30m

- label: Build custom node.js artifacts with glibc 2.17 for arm64
command:
- scripts/create_build_images.sh
- scripts/build_nodejs.sh
- scripts/upload_nodejs_artifacts.sh
env:
ARCH: arm64
agents:
queue: c2-60 # cross-compiling takes a while
timeout_in_minutes: 180 # ideally runs in ~2hr

- wait

- label: Fix SHASUMS256.txt with newly built files' hashes
command:
- scripts/replace_sha_hashes.sh
agents:
queue: kibana-default
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.vscode
.idea

workdir
workdir/
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,46 @@
# kibana-custom-nodejs-builds
Contains configuration and sources to build node.js for custom platforms
Contains configuration and sources to build node.js

The main usecase right now is building `node.js@18+` with `glibc@2.17`, which is required for some older platforms. (More context: https://github.com/nodejs/unofficial-builds/pull/69)

## Running locally
You can run most scripts locally on Mac/Linux. You'll need a few of the build/infra tools:
- Docker
- node.js
- gsutil (`brew install google-cloud-sdk`)

Export some env variables required for the builds
```sh
export ARCH="arm64"
export TARGET_VERSION="18.16.1"
```

Then run individual scripts locally:
```sh
./scripts/create_build_images.sh
./scripts/build_nodejs.sh
```

## Docker image for node.js builds
One of the main components we need to create in this step is a docker image for an environment that's set up for building `node.js`.

The bits for this component are in the [build-image-config](./build-image-config/) folder.

The docker image uses mounted directories as working directories, as well as outputting the artifacts in these directories.


## Scripts for running the builds
Most of the `buildkite` logic is sheltered in the [scripts](./scripts/) directory.



## Context
During development, we found some more information that can be helpful as context, should anyone find this repo again

- This repository is only needed while
- centos:7 / RHEL7 is supported by Elastic, and we ship node.js with Kibana
- the unofficial-builds repo accepts a linux/arm64 build (https://github.com/nodejs/unofficial-builds/pull/83)
- The created Docker images needn't be pushed
- they can be used once for the build, then rebuilt in case we need to run it again
- I decided to remove the `VARIATION` attribute on the node.js:
- build would result in the variation showing up in the file and folder names, making the logistics more difficult, if we want to keep this mostly transparent for Kibana
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ RUN ulimit -n 1024 \
glibc-devel

COPY --chown=node:node entrypoint.sh /home/node/entrypoint.sh
COPY --chown=node:node re2_entrypoint.sh /home/node/re2_entrypoint.sh

USER node

Expand Down
8 changes: 6 additions & 2 deletions ...custom-nodejs-builder-arm64/entrypoint.sh → build-image-config/entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ set -x

release_url_base="$1"
full_version="$2"
config_flags=${3:-""} #"--without-dtrace --without-npm --without-etw"
config_flags=${3:-""}

if [[ $(arch) == x86_64 ]]; then
architecture="x64";
else
architecture="arm64"
fi

ls -la "/home/node/workdir/src"
ls -la "/home/node/workdir/src/node-${full_version}"

cd "/home/node/workdir/src/node-${full_version}"

# Compile from source
Expand All @@ -25,10 +28,11 @@ export CXX="ccache g++"
make -j"$(getconf _NPROCESSORS_ONLN)" binary V= \
DESTCPU="$architecture" \
ARCH="$architecture" \
VARIATION="glibc-217" \
DISTTYPE="release" \
RELEASE_URLBASE="$release_url_base" \
CONFIG_FLAGS="$config_flags"

mkdir -p /home/node/workdir/dist/
chmod a+w /home/node/workdir/dist
mv node-*.tar.?z /home/node/workdir/dist/
chmod a+rwx /home/node/workdir/dist/*
18 changes: 0 additions & 18 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,3 @@ metadata:
links:
- title: Pipeline
url: https://buildkite.com/elastic/kibana-custom-nodejs-builds

spec:
type: buildkite-pipeline
owner: group:kibana-operations
system: buildkite
implementation:
apiVersion: buildkite.elastic.dev/v1
kind: Pipeline
metadata:
name: kibana-custom-nodejs-builds
spec:
repository: elastic/kibana-custom-nodejs-builds
pipeline_file: ".buildkite/pipeline.yml"
teams:
kibana-operations:
access_level: MANAGE_BUILD_AND_READ
everyone:
access_level: READ_ONLY
13 changes: 0 additions & 13 deletions containers/custom-nodejs-builder-amd64/drivah.toml

This file was deleted.

34 changes: 0 additions & 34 deletions containers/custom-nodejs-builder-amd64/entrypoint.sh

This file was deleted.

55 changes: 0 additions & 55 deletions containers/custom-nodejs-builder-amd64/re2_entrypoint.sh

This file was deleted.

31 changes: 0 additions & 31 deletions containers/custom-nodejs-builder-arm64/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions containers/custom-nodejs-builder-arm64/drivah.toml

This file was deleted.

55 changes: 0 additions & 55 deletions containers/custom-nodejs-builder-arm64/re2_entrypoint.sh

This file was deleted.

Loading