Skip to content

Commit 455feab

Browse files
committed
Adding logic to autobuild the node binary
- Added logic automatically build the node binary tag and push it up to docker if the version set in circle.yml isn't found in the registry. - Will tag it with both a circleci build number and the expected generic tag so that both are available and neither should affect the :latest tag. - Increased Major Version tag to 2 - Adding Packages needed for building.
1 parent bf5bc16 commit 455feab

3 files changed

Lines changed: 32 additions & 7 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
pkr_files/**
22
tf_files/**
3+
node_files.tar.gz
4+
node_files

Dockerfile-build-node

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM unifio/covalence:latest
22
MAINTAINER "WhistleLabs, Inc. <devops@whistle.com>"
33

4+
LABEL node_version="7.5.0"
5+
46
ENV VERSION=v7.5.0 NPM_VERSION=4
57
#ENV CONFIG_FLAGS="--fully-static --without-npm" DEL_PKGS="libstdc++" RM_DIRS=/usr/include
68

circle.yml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
machine:
22
environment:
3-
MAJOR_VERSION_TAG: 1
3+
MAJOR_VERSION_TAG: 2
44
PACKER_VERSION_TAG: 0.12.0
55
TERRAFORM_VERSION_TAG: 0.8.8
66
NODE_VERSION_TAG: 7.5.0
@@ -15,7 +15,7 @@ machine:
1515

1616
dependencies:
1717
pre:
18-
- sudo apt-get install jq
18+
- sudo apt-get update; sudo apt-get install jq curl curl-dev python-dev
1919
cache_directories:
2020
- "~/docker"
2121
override:
@@ -25,7 +25,16 @@ dependencies:
2525
if [[ $(./tagexists.sh ${CI_IMAGE_NAME}) == "1" ]];then
2626
./copybins.sh node && \
2727
echo node >> ~/.allbinaries && echo npm >> ~/.allbinaries
28-
fi
28+
else
29+
echo "Building Node.js binary image. ${CI_NODE_IMAGE_NAME} was not found."
30+
echo "The build will take about 40 minutes to complete."
31+
if docker build -f Dockerfile-build-node --rm=false -t "${CI_NODE_IMAGE_NAME}" .; then
32+
echo newJStag >> ~/.allbinaries
33+
echo "${CI_NODE_IMAGE_NAME} has been built and will be pushed to dockerhhub"
34+
./copybins.sh node && \
35+
echo node >> ~/.allbinaries && echo npm >> ~/.allbinaries
36+
fi
37+
fi
2938
- >
3039
if [[ $(DOCKER_BIN_TAG="${TERRAFORM_VERSION_TAG}" ./tagexists.sh ${TF_IMAGE}) == "1" ]];then
3140
./copybins.sh terraform && \
@@ -63,6 +72,11 @@ test:
6372
docker run -e CHECKPOINT_DISABLE=1 \
6473
--entrypoint /bin/sh "${CI_IMAGE_NAME}" -c "terraform version"
6574
fi
75+
- >
76+
if grep -q newJStag ~/.allbinaries; then
77+
echo "The ${CI_NODE_IMAGE_NAME} was built but still needs to be pushed to docker hub."
78+
docker run --entrypoint /bin/sh "${CI_IMAGE_NAME}:${DOCKER_BIN_TAG}" -c "node --version"
79+
fi
6680
- >
6781
if grep -q node ~/.allbinaries; then
6882
docker run --entrypoint /bin/sh "${CI_IMAGE_NAME}" -c "node --version"
@@ -82,8 +96,15 @@ deployment:
8296
if grep -q node ~/.allbinaries; then
8397
docker tag "${IMAGE_TO_TAG}" \
8498
"${CI_IMAGE_NAME}":${PACKER_VERSION_TAG}.${TERRAFORM_VERSION_TAG}.${NODE_VERSION_TAG}.${CIRCLE_BUILD_NUM}
85-
else
86-
docker tag "${IMAGE_TO_TAG}" \
87-
"${CI_IMAGE_NAME}":${PACKER_VERSION_TAG}.${TERRAFORM_VERSION_TAG}.${CIRCLE_BUILD_NUM}
88-
fi
99+
if grep -q newJStag ~/.allbinaries; then
100+
IMAGE_TO_TAG=$(docker images | grep -E "${DOCKER_BIN_TAG}" | awk '{print $3}')
101+
docker tag "${IMAGE_TO_TAG}" \
102+
${CI_IMAGE_NAME}:${DOCKER_BIN_TAG}.${CIRCLE_BUILD_NUM} && \
103+
docker push "${CI_IMAGE_NAME}":${DOCKER_BIN_TAG}.${CIRCLE_BUILD_NUM} && \
104+
docker push "${CI_IMAGE_NAME}":${DOCKER_BIN_TAG}
105+
fi
106+
else
107+
docker tag "${IMAGE_TO_TAG}" \
108+
"${CI_IMAGE_NAME}":${PACKER_VERSION_TAG}.${TERRAFORM_VERSION_TAG}.${CIRCLE_BUILD_NUM}
109+
fi
89110
- docker push "${CI_IMAGE_NAME}"

0 commit comments

Comments
 (0)