Skip to content

Commit 36eb23e

Browse files
authored
Merge pull request #105 from murgatroid99/alpine_build
Add Alpine build script and Dockerfile, improve existing build scripts
2 parents 89c60cb + 0ab70b9 commit 36eb23e

File tree

5 files changed

+122
-29
lines changed

5 files changed

+122
-29
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM node:8-alpine
2+
RUN apk add --no-cache python curl bash build-base
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
# Copyright 2017 gRPC authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
source ~/.nvm/nvm.sh
17+
18+
nvm install 8
19+
set -ex
20+
21+
cd $(dirname $0)
22+
tool_dir=$(pwd)
23+
cd $tool_dir/../../..
24+
base_dir=$(pwd)
25+
26+
export ARTIFACTS_OUT=$base_dir/artifacts
27+
28+
rm -rf build || true
29+
30+
mkdir -p "${ARTIFACTS_OUT}"
31+
32+
docker build -t alpine_node_artifact $base_dir/tools/docker/alpine_artifact
33+
34+
$tool_dir/build_artifact_node.sh
35+
36+
$tool_dir/build_artifact_node_arm.sh
37+
38+
docker run -e ARTIFACTS_OUT=/var/grpc/artifacts -v $base_dir:/var/grpc alpine_node_artifact bash -c /var/grpc/tools/run_tests/artifacts/build_artifact_node.sh --with-alpine

packages/grpc-native-core/tools/run_tests/artifacts/build_artifact_node.bat

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
@rem See the License for the specific language governing permissions and
1313
@rem limitations under the License.
1414

15+
set arch_list=ia32 x64
16+
1517
set node_versions=4.0.0 5.0.0 6.0.0 7.0.0 8.0.0 9.0.0
1618

1719
set electron_versions=1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0
@@ -24,21 +26,23 @@ call npm update || goto :error
2426

2527
mkdir -p %ARTIFACTS_OUT%
2628

27-
for %%v in (%node_versions%) do (
28-
call .\node_modules\.bin\node-pre-gyp.cmd configure build --target=%%v --target_arch=%1
29+
for %%a in (%arch_list%) do (
30+
for %%v in (%node_versions%) do (
31+
call .\node_modules\.bin\node-pre-gyp.cmd configure build --target=%%v --target_arch=%%a
2932

30-
@rem Try again after removing openssl headers
31-
rmdir "%USERPROFILE%\.node-gyp\%%v\include\node\openssl" /S /Q
32-
rmdir "%USERPROFILE%\.node-gyp\iojs-%%v\include\node\openssl" /S /Q
33-
call .\node_modules\.bin\node-pre-gyp.cmd build package --target=%%v --target_arch=%1 || goto :error
33+
@rem Try again after removing openssl headers
34+
rmdir "%USERPROFILE%\.node-gyp\%%v\include\node\openssl" /S /Q
35+
rmdir "%USERPROFILE%\.node-gyp\iojs-%%v\include\node\openssl" /S /Q
36+
call .\node_modules\.bin\node-pre-gyp.cmd build package --target=%%v --target_arch=%%a || goto :error
3437

35-
xcopy /Y /I /S build\stage\* %ARTIFACTS_OUT%\ || goto :error
36-
)
38+
xcopy /Y /I /S build\stage\* %ARTIFACTS_OUT%\ || goto :error
39+
)
3740

38-
for %%v in (%electron_versions%) do (
39-
cmd /V /C "set "HOME=%USERPROFILE%\electron-gyp" && call .\node_modules\.bin\node-pre-gyp.cmd configure rebuild package --runtime=electron --target=%%v --target_arch=%1 --disturl=https://atom.io/download/electron" || goto :error
41+
for %%v in (%electron_versions%) do (
42+
cmd /V /C "set "HOME=%USERPROFILE%\electron-gyp" && call .\node_modules\.bin\node-pre-gyp.cmd configure rebuild package --runtime=electron --target=%%v --target_arch=%%a --disturl=https://atom.io/download/electron" || goto :error
4043

41-
xcopy /Y /I /S build\stage\* %ARTIFACTS_OUT%\ || goto :error
44+
xcopy /Y /I /S build\stage\* %ARTIFACTS_OUT%\ || goto :error
45+
)
4246
)
4347
if %errorlevel% neq 0 exit /b %errorlevel%
4448

packages/grpc-native-core/tools/run_tests/artifacts/build_artifact_node.sh

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,24 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
NODE_TARGET_ARCH=$1
17-
NODE_TARGET_OS=$2
18-
source ~/.nvm/nvm.sh
16+
NODE_ALPINE_BUILD=false
1917

20-
nvm use 8
21-
set -ex
18+
while true ; do
19+
case $1 in
20+
--with-alpine)
21+
NODE_ALPINE_BUILD=true
22+
;;
23+
"")
24+
;;
25+
*)
26+
echo "Unknown parameter: $1"
27+
exit 1
28+
;;
29+
esac
30+
shift || break
31+
done
32+
33+
NODE_ALPINE_BUILD=$1
2234

2335
umask 022
2436

@@ -30,24 +42,25 @@ mkdir -p "${ARTIFACTS_OUT}"
3042

3143
npm update
3244

45+
arch_list=( ia32 x64 )
46+
3347
node_versions=( 4.0.0 5.0.0 6.0.0 7.0.0 8.0.0 9.0.0 )
3448

3549
electron_versions=( 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 )
3650

37-
for version in ${node_versions[@]}
51+
for arch in ${arch_list[@]}
3852
do
39-
./node_modules/.bin/node-pre-gyp configure rebuild package --target=$version --target_arch=$NODE_TARGET_ARCH --grpc_alpine=true
40-
cp -r build/stage/* "${ARTIFACTS_OUT}"/
41-
if [ "$NODE_TARGET_ARCH" == 'x64' ] && [ "$NODE_TARGET_OS" == 'linux' ]
42-
then
43-
# Cross compile for ARM on x64
44-
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ LD=arm-linux-gnueabihf-g++ ./node_modules/.bin/node-pre-gyp configure rebuild package testpackage --target=$version --target_arch=arm
53+
for version in ${node_versions[@]}
54+
do
55+
./node_modules/.bin/node-pre-gyp configure rebuild package --target=$version --target_arch=$arch --grpc_alpine=$NODE_ALPINE_BUILD
4556
cp -r build/stage/* "${ARTIFACTS_OUT}"/
46-
fi
47-
done
57+
done
4858

49-
for version in ${electron_versions[@]}
50-
do
51-
HOME=~/.electron-gyp ./node_modules/.bin/node-pre-gyp configure rebuild package --runtime=electron --target=$version --target_arch=$NODE_TARGET_ARCH --disturl=https://atom.io/download/electron
52-
cp -r build/stage/* "${ARTIFACTS_OUT}"/
59+
for version in ${electron_versions[@]}
60+
do
61+
HOME=~/.electron-gyp ./node_modules/.bin/node-pre-gyp configure rebuild package --runtime=electron --target=$version --target_arch=$arch --disturl=https://atom.io/download/electron
62+
cp -r build/stage/* "${ARTIFACTS_OUT}"/
63+
done
5364
done
65+
66+
rm -rf build || true
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
# Copyright 2017 gRPC authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
source ~/.nvm/nvm.sh
17+
18+
nvm use 8
19+
set -ex
20+
21+
cd $(dirname $0)/../../..
22+
23+
rm -rf build || true
24+
25+
mkdir -p "${ARTIFACTS_OUT}"
26+
27+
npm update
28+
29+
node_versions=( 4.0.0 5.0.0 6.0.0 7.0.0 8.0.0 9.0.0 )
30+
31+
for version in ${node_versions[@]}
32+
do
33+
# Cross compile for ARM on x64
34+
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ LD=arm-linux-gnueabihf-g++ ./node_modules/.bin/node-pre-gyp configure rebuild package testpackage --target=$version --target_arch=arm
35+
cp -r build/stage/* "${ARTIFACTS_OUT}"/
36+
done

0 commit comments

Comments
 (0)