Skip to content

Commit

Permalink
Enable ccache for Alpine builds on Travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello committed Nov 21, 2018
1 parent 71b7279 commit 7e5b3f0
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ services:
echo "Skip build of $Dockerfile as it's not changed."
exit
fi
if [ "alpine" = "$VARIANT" ]; then
mkdir -p ccache
(
cd ccache
ls -l
md5sum *
nc -v -l -p 5678 -q 1 < cache.tgz &
nc -v -l -p 1234 -q 1 > new-cache.tgz &
)
fi
script: ./test-build.sh $NODE_VERSION $VARIANT

Expand Down Expand Up @@ -116,6 +126,16 @@ jobs:
- NODE_VERSION: "10"
- VARIANT: "alpine"

before_cache:
- ls -hl ccache/
- ls -l ccache/
- file ccache/*
- md5sum ccache/*
- mv ccache/new-cache.tgz ccache/cache.tgz
cache:
directories:
- ccache/

- stage: Build
before_script: *auto_skip
env:
Expand All @@ -134,6 +154,16 @@ jobs:
- NODE_VERSION: "11"
- VARIANT: "alpine"

before_cache:
- ls -hl ccache/
- ls -l ccache/
- file ccache/*
- md5sum ccache/*
- mv ccache/new-cache.tgz ccache/cache.tgz
cache:
directories:
- ccache/

- stage: Build
before_script: *auto_skip
env:
Expand All @@ -158,6 +188,16 @@ jobs:
- NODE_VERSION: "6"
- VARIANT: "alpine"

before_cache:
- ls -hl ccache/
- ls -l ccache/
- file ccache/*
- md5sum ccache/*
- mv ccache/new-cache.tgz ccache/cache.tgz
cache:
directories:
- ccache/

- stage: Build
before_script: *auto_skip
env:
Expand Down Expand Up @@ -188,6 +228,16 @@ jobs:
- NODE_VERSION: "8"
- VARIANT: "alpine"

before_cache:
- ls -hl ccache/
- ls -l ccache/
- file ccache/*
- md5sum ccache/*
- mv ccache/new-cache.tgz ccache/cache.tgz
cache:
directories:
- ccache/

- stage: Build
before_script: *auto_skip
env:
Expand Down
11 changes: 11 additions & 0 deletions 10/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ RUN addgroup -g 1000 node \
curl \
g++ \
gcc \
ccache \
netcat-openbsd \
gnupg \
libgcc \
linux-headers \
Expand Down Expand Up @@ -38,10 +40,19 @@ RUN addgroup -g 1000 node \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
&& ln -s /usr/bin/ccache /usr/local/bin/cc \
&& ln -s /usr/bin/ccache /usr/local/bin/gcc \
&& ln -s /usr/bin/ccache /usr/local/bin/g++ \
&& HOST_IP="$(ip route | awk '/default/ { print $3 }')" \
&& nc -v "$HOST_IP" 5678 | tar -xz -C / || true \
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& rm -f /usr/local/bin/gcc /usr/local/bin/g++ \
&& ccache -s 1>&2 \
&& apk del .build-deps \
&& tar -czf - /root/.ccache/ | nc -v -w 3 "$HOST_IP" 1234 \
&& rm -rf /root/.ccache/ \
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
Expand Down
11 changes: 11 additions & 0 deletions 11/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ RUN addgroup -g 1000 node \
curl \
g++ \
gcc \
ccache \
netcat-openbsd \
gnupg \
libgcc \
linux-headers \
Expand Down Expand Up @@ -38,10 +40,19 @@ RUN addgroup -g 1000 node \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
&& ln -s /usr/bin/ccache /usr/local/bin/cc \
&& ln -s /usr/bin/ccache /usr/local/bin/gcc \
&& ln -s /usr/bin/ccache /usr/local/bin/g++ \
&& HOST_IP="$(ip route | awk '/default/ { print $3 }')" \
&& nc -v "$HOST_IP" 5678 | tar -xz -C / || true \
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& rm -f /usr/local/bin/gcc /usr/local/bin/g++ \
&& ccache -s 1>&2 \
&& apk del .build-deps \
&& tar -czf - /root/.ccache/ | nc -v -w 3 "$HOST_IP" 1234 \
&& rm -rf /root/.ccache/ \
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
Expand Down
11 changes: 11 additions & 0 deletions 6/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ RUN addgroup -g 1000 node \
curl \
g++ \
gcc \
ccache \
netcat-openbsd \
gnupg \
libgcc \
linux-headers \
Expand Down Expand Up @@ -38,10 +40,19 @@ RUN addgroup -g 1000 node \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
&& ln -s /usr/bin/ccache /usr/local/bin/cc \
&& ln -s /usr/bin/ccache /usr/local/bin/gcc \
&& ln -s /usr/bin/ccache /usr/local/bin/g++ \
&& HOST_IP="$(ip route | awk '/default/ { print $3 }')" \
&& nc -v "$HOST_IP" 5678 | tar -xz -C / || true \
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& rm -f /usr/local/bin/gcc /usr/local/bin/g++ \
&& ccache -s 1>&2 \
&& apk del .build-deps \
&& tar -czf - /root/.ccache/ | nc -v -w 3 "$HOST_IP" 1234 \
&& rm -rf /root/.ccache/ \
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
Expand Down
11 changes: 11 additions & 0 deletions 8/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ RUN addgroup -g 1000 node \
curl \
g++ \
gcc \
ccache \
netcat-openbsd \
gnupg \
libgcc \
linux-headers \
Expand Down Expand Up @@ -38,10 +40,19 @@ RUN addgroup -g 1000 node \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
&& ln -s /usr/bin/ccache /usr/local/bin/cc \
&& ln -s /usr/bin/ccache /usr/local/bin/gcc \
&& ln -s /usr/bin/ccache /usr/local/bin/g++ \
&& HOST_IP="$(ip route | awk '/default/ { print $3 }')" \
&& nc -v "$HOST_IP" 5678 | tar -xz -C / || true \
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& rm -f /usr/local/bin/gcc /usr/local/bin/g++ \
&& ccache -s 1>&2 \
&& apk del .build-deps \
&& tar -czf - /root/.ccache/ | nc -v -w 3 "$HOST_IP" 1234 \
&& rm -rf /root/.ccache/ \
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile-alpine.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ RUN addgroup -g 1000 node \
curl \
g++ \
gcc \
ccache \
netcat-openbsd \
gnupg \
libgcc \
linux-headers \
Expand All @@ -30,10 +32,19 @@ RUN addgroup -g 1000 node \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
&& ln -s /usr/bin/ccache /usr/local/bin/cc \
&& ln -s /usr/bin/ccache /usr/local/bin/gcc \
&& ln -s /usr/bin/ccache /usr/local/bin/g++ \
&& HOST_IP="$(ip route | awk '/default/ { print $3 }')" \
&& nc -v "$HOST_IP" 5678 | tar -xz -C / || true \
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& rm -f /usr/local/bin/gcc /usr/local/bin/g++ \
&& ccache -s 1>&2 \
&& apk del .build-deps \
&& tar -czf - /root/.ccache/ | nc -v -w 3 "$HOST_IP" 1234 \
&& rm -rf /root/.ccache/ \
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
Expand Down
10 changes: 10 additions & 0 deletions travis.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ services:
echo "Skip build of $Dockerfile as it's not changed."
exit
fi
if [ "alpine" = "$VARIANT" ]; then
mkdir -p ccache
(
cd ccache
ls -l
md5sum *
nc -v -l -p 5678 -q 1 < cache.tgz &
nc -v -l -p 1234 -q 1 > new-cache.tgz &
)
fi

script: ./test-build.sh $NODE_VERSION $VARIANT

Expand Down
12 changes: 12 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ function add_stage() {
env:
- NODE_VERSION: "'"${version}"'"
- VARIANT: "'"${variant}"'"' >> .travis.yml
if [ "alpine" = "${variant}" ]; then
echo '
before_cache:
- ls -hl ccache/
- ls -l ccache/
- file ccache/*
- md5sum ccache/*
- mv ccache/new-cache.tgz ccache/cache.tgz
cache:
directories:
- ccache/' >> .travis.yml
fi
}

echo '# DO NOT MODIFY. THIS FILE IS AUTOGENERATED #
Expand Down

0 comments on commit 7e5b3f0

Please sign in to comment.