Skip to content
This repository was archived by the owner on May 23, 2021. It is now read-only.

Commit 2fc72be

Browse files
committed
Use docker for releases
1 parent da291ee commit 2fc72be

File tree

8 files changed

+96
-38
lines changed

8 files changed

+96
-38
lines changed

.travis.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@ language: node_js
22
osx_image: xcode10.2
33
node_js:
44
- 10.15.1
5+
services:
6+
- docker
57
cache:
68
directories:
79
- /home/travis/.ccache/
10+
- /home/travis/.centos-ccache/
11+
- /home/travis/.alpine-ccache
812
before_install:
913
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache; fi
1014
- export PATH="/usr/local/opt/ccache/libexec:$PATH"
1115
- eval "$(MATRIX_EVAL)"
1216
matrix:
1317
include:
1418
- os: linux
15-
dist: xenial
16-
addons:
17-
apt:
18-
packages:
19-
- gcc-multilib
20-
- g++-multilib
2119
- os: osx
22-
script: scripts/ci.sh && scripts/test.sh
20+
script: scripts/ci.sh
2321
deploy:
2422
provider: gcs
2523
access_key_id: GOOGZVNTORC5JOVTMMRVCXAM

Dockerfile renamed to alpine.dockerfile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@ FROM node:10.15.1-alpine
44

55
RUN apk update
66
RUN apk add bash
7-
87
RUN apk add gcc
98
RUN apk add g++
9+
RUN apk add ccache
1010
RUN apk add git
1111
RUN apk add make
1212
RUN apk add python
1313
RUN apk add linux-headers
14-
15-
RUN mkdir /nbin
16-
COPY . /nbin
17-
18-
ENTRYPOINT [ "/bin/bash" ]

centos.dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM centos:7
2+
3+
RUN yum install -y centos-release-scl
4+
RUN yum-config-manager --enable rhel-server-rhscl-7-rpms
5+
RUN yum install -y devtoolset-6
6+
RUN yum install -y gcc-c++
7+
RUN rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/c/ccache-3.3.4-1.el7.x86_64.rpm
8+
9+
RUN mkdir /root/node
10+
RUN cd /root/node && curl https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz | tar xJ --strip-components=1 --
11+
RUN ln -s /root/node/bin/node /usr/bin/node
12+
ENV PATH "$PATH:/root/node/bin"
13+
RUN npm install -g yarn
14+
15+
# VOLUME ~/.ccache /ccache
16+
# RUN source /opt/rh/devtoolset-6/enable && scripts/node_build.sh
17+
# RUN npm rebuild
18+
# RUN npm

scripts/ci.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
#!/bin/bash
22

3-
set -e
3+
set -euox pipefail
44

55
cd "$(dirname "$0")"
6+
source ./vars.sh
7+
68
./patch_apply.sh
79
./webpack_build.sh
8-
./node_build.sh
10+
11+
cp ./node_build.sh ../lib/node/build.sh
12+
mkdir -p ./build/$PACKAGE_VERSION
13+
14+
if [[ "$OSTYPE" == "darwin"* ]]; then
15+
./mac_build.sh
16+
else
17+
./docker_build.sh
18+
fi

scripts/docker_build.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
set -eoux pipefail
4+
5+
cd "$(dirname "$0")"
6+
source ./vars.sh
7+
8+
# Variables to be set:
9+
# $CACHE_DIR
10+
# $IMAGE
11+
# $PREBUILD_COMMAND
12+
# $BINARY_NAME
13+
function docker_build() {
14+
containerID=$(docker create -it -v $HOME/$CACHE_DIR:/ccache $IMAGE)
15+
docker start $containerID
16+
docker exec $containerID mkdir /src
17+
18+
function exec() {
19+
docker exec -w /src $containerID bash -c "$@"
20+
}
21+
22+
docker cp ../. $containerID:/src
23+
exec "$PREBUILD_COMMAND/src/lib/node/build.sh"
24+
exec "npm rebuild"
25+
exec "npm test"
26+
docker cp $containerID:/src/lib/node/out/Release/node ../build/$PACKAGE_VERSION/$BINARY_NAME
27+
}
28+
29+
CACHE_DIR=".ccache-centos"
30+
IMAGE="codercom/nbin-centos"
31+
PREBUILD_COMMAND="source /opt/rh/devtoolset-6/enable &&"
32+
BINARY_NAME="node-${NODE_VERSION}-linux-x64"
33+
docker_build
34+
35+
CACHE_DIR=".ccache-alpine"
36+
IMAGE="codercom/nbin-alpine"
37+
PREBUILD_COMMAND=""
38+
BINARY_NAME="node-${NODE_VERSION}-alpine-x64"
39+
docker_build

scripts/mac_build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
cd "$(dirname "$0")"
4+
source ./vars.sh
5+
cd ../lib/node
6+
7+
export CCACHE_DIR="/ccache"
8+
./build.sh
9+
10+
ARCH=$(uname -m)
11+
BINARY_NAME="node-${NODE_VERSION}-darwin-x64"
12+
13+
cp ./out/Release/node ../../build/$PACKAGE_VERSION/$BINARY_NAME

scripts/node_build.sh

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,21 @@
11
#!/bin/bash
22

33
cd "$(dirname "$0")"
4-
source ./vars.sh
5-
cd ../lib/node
4+
set -euxo pipefail
65

76
export CC="ccache gcc"
8-
export CXX='ccache g++'
9-
echo "Configuring with --dest-cpu=x64"
7+
export CXX="ccache g++"
8+
export CCACHE_DIR="/ccache"
109
./configure --link-module './nbin.js' --link-module './lib/_third_party_main.js' --dest-cpu=x64 --openssl-no-asm
11-
make -j2 &>/dev/null &
10+
cores=$(cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l)
11+
make -j$cores &>/dev/null &
1212
pid=$!
1313
(
1414
while true; do
15-
echo still running
15+
echo Compiling...
1616
sleep 60
1717
done
1818
) &
19+
subshell=$!
1920
wait "$pid"
20-
cd ../../
21-
22-
mkdir -p ./build/$PACKAGE_VERSION
23-
24-
if [[ "$OSTYPE" == "linux-gnu" ]]; then
25-
OS="linux"
26-
elif [[ "$OSTYPE" == "linux-musl" ]]; then
27-
OS="alpine"
28-
elif [[ "$OSTYPE" == "darwin"* ]]; then
29-
OS="darwin"
30-
fi
31-
32-
ARCH=$(uname -m)
33-
BINARY_NAME="node-${NODE_VERSION}-${OS}-${ARCH}"
34-
35-
cp ./lib/node/out/Release/node ./build/$PACKAGE_VERSION/$BINARY_NAME
21+
kill -9 $subshell

scripts/vars.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22

3-
cd "$(dirname "$0")"
43
NODE_VERSION=10.15.1
54
PACKAGE_VERSION=$(cat ../package.json \
65
| grep version \

0 commit comments

Comments
 (0)