Skip to content

Commit dd56c54

Browse files
authored
Automatic dockerhub builds (#408)
This change adds three main things: 1. Pushing a lyft/envoy:latest image to dockerhub every time master passes tests. 2. Check that the docker examples work on every PR. 3. Add SHA versioned lyft/envoy-build images.
1 parent 4c887e0 commit dd56c54

File tree

10 files changed

+110
-12
lines changed

10 files changed

+110
-12
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ env:
1414
- TEST_TYPE=docs
1515
script:
1616
- travis lint .travis.yml --skip-completion-check
17-
- docker run -t -i -v $TRAVIS_BUILD_DIR:/source lyft/envoy-build:latest /bin/bash -c "cd /source && ci/do_ci.sh $TEST_TYPE"
17+
- docker run -t -i -v $TRAVIS_BUILD_DIR:/source lyft/envoy-build:4c887e005b129b28d815d59f9983b1ed3eb9568f /bin/bash -c "cd /source && ci/do_ci.sh $TEST_TYPE"
18+
- ./ci/docker_push.sh
19+
- ./ci/verify_examples.sh

examples/Dockerfile-envoy-image renamed to ci/Dockerfile-envoy-image

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ FROM ubuntu:14.04
22

33
ADD build/source/exe/envoy /usr/local/bin/envoy
44
RUN apt-get update && apt-get install -y \
5-
curl \
6-
python-pip
5+
build-essential
6+
RUN strip /usr/local/bin/envoy
7+
RUN apt-get purge -y build-essential

ci/build_container/README.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
## Steps to publish new image for Envoy 3rd party dependencies
22

3-
Currently this can be done only by Envoy team.
3+
*Currently this can be done only by Envoy team*
44

5-
* Modify [build_container.sh](build_container.sh) to include steps for building 3rd party library.
6-
* Build image locally by running `docker build --rm -t lyft/envoy-build:latest .` from this directory.
7-
* Login into docker hub by running `docker login`. Make sure to create account beforehand and get that added to Lyft team.
8-
* Publish image by running `docker push lyft/envoy-build:latest`.
5+
After you have made changes to `build_container.sh` and merge them to master:
6+
7+
1. Checkout master and pull latest changes.
8+
2. Get the SHA of the master commit of your changes to `build_container.sh`.
9+
3. From `~/envoy/ci/build_container` run `update_build_container.sh`. **Make sure to have
10+
DOCKER_USERNAME and DOCKER_PASSWORD environment variables set**. This script will build
11+
the envoy-build container with the current state of `build_container.sh`, tag the image
12+
with the SHA provided, and push it to Dockerhub.
13+
4. After you have done that, update `.travis.yml` to pull the new tagged version of `lyft/envoy-build`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
read -r -p "Do you have master checked out with most recent changes? [y/N] " response
3+
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
4+
then
5+
TAG="$(git rev-parse master)"
6+
docker-machine start default
7+
eval $(docker-machine env default)
8+
docker build --rm -t lyft/envoy-build:$TAG .
9+
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
10+
docker push lyft/envoy-build:$TAG
11+
echo Pushed lyft/envoy-build:$TAG
12+
docker tag lyft/envoy-build:$TAG lyft/envoy-build:latest
13+
docker push lyft/envoy-build:latest
14+
fi

ci/docker_push.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -ev
3+
4+
if [ "$TEST_TYPE" == "normal" ]
5+
then
6+
# this is needed to verify the example images
7+
docker build -f ci/Dockerfile-envoy-image -t lyft/envoy:latest .
8+
9+
# push the envoy image on merge to master
10+
want_push='false'
11+
for branch in "master"
12+
do
13+
if [ "$TRAVIS_BRANCH" == "$branch" ]
14+
then
15+
want_push='true'
16+
fi
17+
done
18+
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$want_push" == "true" ]
19+
then
20+
docker login -e $DOCKER_EMAIL -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
21+
docker push lyft/envoy:latest
22+
else
23+
echo 'Ignoring PR branch for docker push.'
24+
fi
25+
fi

ci/verify_examples.sh

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
set -ev
3+
verify() {
4+
echo $1
5+
CONTAINER_ID="$(docker ps -aqf name=$1)"
6+
if [ "false" == "$(docker inspect -f {{.State.Running}} ${CONTAINER_ID})" ]
7+
then
8+
echo "error: $1 not running"
9+
exit 1
10+
fi
11+
}
12+
13+
if [ "$TEST_TYPE" == "normal" ]
14+
then
15+
# Test front proxy example
16+
cd examples/front-proxy
17+
docker-compose up --build -d
18+
for CONTAINER_NAME in "frontproxy_front-envoy" "frontproxy_service1" "frontproxy_service2"
19+
do
20+
verify $CONTAINER_NAME
21+
done
22+
cd ../
23+
24+
# Test grpc bridge example
25+
# install go
26+
curl -O https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz
27+
tar -xf go1.7.1.linux-amd64.tar.gz
28+
sudo mv go /usr/local
29+
export PATH=$PATH:/usr/local/go/bin
30+
export GOPATH=$HOME/go
31+
mkdir -p $GOPATH/src/github.com/lyft/envoy/examples/
32+
cp -r grpc-bridge $GOPATH/src/github.com/lyft/envoy/examples/
33+
# build example
34+
cd $GOPATH/src/github.com/lyft/envoy/examples/grpc-bridge
35+
./script/bootstrap
36+
./script/build
37+
# verify example works
38+
docker-compose up --build -d
39+
for CONTAINER_NAME in "grpcbridge_python" "grpcbridge_grpc"
40+
do
41+
verify $CONTAINER_NAME
42+
done
43+
else
44+
echo 'Ignoring non-normal build branch'
45+
fi

docs/install/sandboxes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ of the software used to build it.::
308308

309309
$ pwd
310310
src/envoy/
311-
$ docker build -f examples/Dockerfile-envoy-image -t envoy .
311+
$ docker build -f ci/Dockerfile-envoy-image -t envoy .
312312

313313
Now you can use this ``envoy`` image to build the any of the sandboxes if you change
314314
the ``FROM`` line in any dockerfile.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
FROM lyft/envoy:latest
22

3+
RUN apt-get update && apt-get -q install -y \
4+
curl
35
CMD /usr/local/bin/envoy -c /etc/front-envoy.json

examples/front-proxy/Dockerfile-service

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
FROM lyft/envoy:latest
22

3-
RUN pip install Flask==0.11.1
3+
RUN apt-get update && apt-get -q install -y \
4+
curl \
5+
python-pip
6+
RUN pip install -q Flask==0.11.1
47
RUN mkdir /code
58
ADD ./service.py /code
69
ADD ./start_service.sh /usr/local/bin/start_service.sh

examples/grpc-bridge/Dockerfile-python

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
FROM lyft/envoy:latest
22

33
RUN apt-get update
4-
RUN apt-get install -y python-dev
5-
RUN pip install grpcio requests
4+
RUN apt-get -q install -y python-dev \
5+
python-pip
6+
RUN pip install -q grpcio requests
67
ADD ./client /client
78
RUN chmod a+x /client/client.py
89
RUN mkdir /var/log/envoy/

0 commit comments

Comments
 (0)