File tree 3 files changed +34
-17
lines changed
3 files changed +34
-17
lines changed Original file line number Diff line number Diff line change 1
1
# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference
2
2
version : 2.1
3
- # Use a package of configuration called an orb.
4
3
# Orchestrate or schedule a set of jobs
5
4
workflows :
6
5
docker-compose :
7
- # Run the welcome/run job in its own container
8
6
jobs :
9
7
- build-and-test
10
8
jobs :
16
14
name : Install Docker Compose
17
15
command : |
18
16
set -x
19
- curl -L https://github.com/docker/compose/releases/download/1.26.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
20
- sudo chmod +x ~/docker-compose
17
+ curl -L https://github.com/docker/compose/releases/download/1.26.2/docker-compose-`uname -s`-`uname -m` > /home/circleci/bin/docker-compose
18
+ sudo chmod +x /home/circleci/bin/docker-compose
19
+ which docker-compose
20
+ docker-compose --version
21
21
- run :
22
22
command : |
23
23
git clone https://github.com/metacpan/metacpan-docker.git
@@ -36,27 +36,27 @@ jobs:
36
36
- run :
37
37
command : |
38
38
pushd metacpan-docker
39
- ~/ docker-compose build --build-arg CPM_ARGS='--with-test' api_test
39
+ docker-compose build --build-arg CPM_ARGS='--with-test' api_test
40
40
name : compose build
41
41
- run :
42
42
command : |
43
43
pushd metacpan-docker
44
44
./bin/metacpan-docker init
45
- ~/ docker-compose --verbose up -d api_test
45
+ docker-compose --verbose up -d api_test
46
46
name : compose up
47
47
- run :
48
48
command : |
49
- pushd metacpan-docker/src/metacpan-api
50
- ./wait-for-es.sh http://localhost:9200
49
+ pushd metacpan-docker
50
+ ./src/metacpan-api/ wait-for-es.sh http://localhost:9200 elasticsearch_test --
51
51
name : wait for ES
52
52
- run :
53
53
command : |
54
54
pushd metacpan-docker
55
- ~/ docker-compose exec -T api_test prove -lr --jobs 2 t
55
+ docker-compose exec -T api_test prove -lr --jobs 2 t
56
56
- run :
57
57
command : |
58
58
pushd metacpan-docker
59
- ~/ docker-compose logs
59
+ docker-compose logs
60
60
docker stats --no-stream
61
61
docker ps -a | head
62
62
name : docker-compose logs
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ WORKDIR /metacpan-api
9
9
# size of the images.
10
10
RUN mkdir /CPAN \
11
11
&& apt-get update \
12
- && apt-get install -y --no-install-recommends rsync=3.1.3-6 \
12
+ && apt-get install -y --no-install-recommends rsync=3.1.3-6 jq \
13
13
&& apt-get clean \
14
14
&& rm -rf /var/lib/apt/lists/* \
15
15
&& cpm install --global \
Original file line number Diff line number Diff line change 5
5
6
6
set -ux
7
7
8
- host=" $1 "
8
+
9
+ HOST=" $1 "
10
+ CONTAINER=${2:- " " }
11
+ PREAMBLE=" "
12
+
13
+ echo " container |$CONTAINER |"
14
+ if [[ $CONTAINER != " " ]]; then
15
+ PREAMBLE=" docker-compose exec $CONTAINER "
16
+ fi
9
17
10
18
while true ; do
11
- response=$( curl --write-out ' %{http_code}' --silent --fail --output /dev/null " $host " )
19
+ response=$( $PREAMBLE curl --write-out ' %{http_code}' --silent --fail --output /dev/null " $HOST " )
12
20
if [[ " $response " -eq " 200" ]]; then
13
21
break
14
22
fi
21
29
# if the server was not available
22
30
set -e
23
31
32
+ COUNTER=0
33
+ MAX_LOOPS=60
24
34
while true ; do
25
35
# # Wait for ES status to turn to yellow.
26
36
# # TODO: Ideally we'd be waiting for green, but we need multiple nodes for that.
27
- health=" $( curl -fsSL " $host /_cat/health?h= status" ) "
28
- health= " $( echo " $health " | xargs ) " # trim whitespace (otherwise we'll have "green ")
29
- if [[ $health == ' yellow ' || $health == ' green ' ]] ; then
37
+ health=$( $PREAMBLE curl -fsSL " $HOST /_cat/health?format=JSON " | jq ' .[0]. status == "yellow" or .[0].status == "green" ' )
38
+ if [[ $health == ' true ' ]] ; then
39
+ echo " Elasticsearch is up " >&2
30
40
break
31
41
fi
32
42
echo " Elastic Search is unavailable ($health ) - sleeping" >&2
43
+ COUNTER=$(( COUNTER + 1 ))
44
+ if [[ $COUNTER -gt $MAX_LOOPS ]]; then
45
+ echo " Giving up after $COUNTER attempts"
46
+ exit 1
47
+ break
48
+ fi
33
49
sleep 1
34
50
done
35
51
36
- echo " Elastic Search is up" >&2
52
+ # Allow commands to be chained
53
+ shift
37
54
shift
38
55
exec " $@ "
You can’t perform that action at this time.
0 commit comments