forked from spisakt/RPN-signature
-
Notifications
You must be signed in to change notification settings - Fork 1
/
circle.yml
145 lines (136 loc) · 4.24 KB
/
circle.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
version: 2
jobs:
build:
environment:
- TZ: "/usr/share/zoneinfo/America/Los_Angeles"
- RPN_API_TAG: 1.0.6
docker:
- image: docker:18.01.0-ce-git
working_directory: /tmp/src/rpn-signature
steps:
- run:
name: Install parallel gzip and python3
command: apk add --no-cache pigz python3
- restore_cache:
keys:
- docker-v1-{{ .Branch }}-{{ epoch }}
- docker-v1-{{ .Branch }}-
- docker-v1-master-
- docker-v1-
paths:
- /tmp/cache/docker.tar.gz
- /tmp/cache/webapi.tar.gz
- checkout
- setup_remote_docker
- run:
name: Load Docker image layer cache
no_output_timeout: 30m
command: |
docker info
set +o pipefail
if [ -f /tmp/cache/docker.tar.gz ]; then
pigz -d --stdout /tmp/cache/docker.tar.gz | docker load
fi
if [ -f /tmp/cache/webapi.tar.gz ]; then
pigz -d --stdout /tmp/cache/webapi.tar.gz | docker load
fi
docker images
- run:
name: Build Docker image
no_output_timeout: 60m
command: |
# Build docker image
THISVERSION=0
e=1 && for i in {1..5}; do
docker build \
--cache-from=tspisak/rpn-signature \
--rm=false \
-t tspisak/rpn-signature:unstable \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg VERSION="${CIRCLE_TAG}" . \
&& e=0 && break || sleep 15
done && [ "$e" -eq "0" ]
- run:
name: Docker save
no_output_timeout: 40m
command: |
mkdir -p /tmp/cache
docker save ubuntu:xenial-20161213 tspisak/rpn-signature:unstable \
| pigz -2 -p 3 > /tmp/cache/docker.tar.gz
- run:
name: Deploy to Docker Hub
no_output_timeout: 40m
command: |
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker push tspisak/rpn-signature:unstable
- persist_to_workspace:
root: /tmp
paths:
- cache/docker.tar.gz
- cache/rpn-signature.tar.gz
- src/rpn-signature
update_cache:
machine:
# Ubuntu 14.04 with Docker 17.10.0-ce
image: circleci/classic:201711-01
working_directory: /tmp/src/rpn-signature
steps:
- attach_workspace:
at: /tmp
- save_cache:
key: docker-v1-{{ .Branch }}-{{ epoch }}
paths:
- /tmp/cache/docker.tar.gz
- /tmp/cache/rpn-signature.tar.gz
deploy:
machine:
image: circleci/classic:201711-01
working_directory: /tmp/src/rpn-signature
steps:
- attach_workspace:
at: /tmp
- run:
name: Load Docker image layer cache
no_output_timeout: 30m
command: |
docker info
set +o pipefail
if [ -f /tmp/cache/docker.tar.gz ]; then
sudo apt update && sudo apt -y install pigz
pigz -d --stdout /tmp/cache/docker.tar.gz | docker load
docker images
fi
- run:
name: Deploy to Docker Hub
no_output_timeout: 40m
command: |
if [[ -n "$CIRCLE_TAG" ]]; then
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker tag tspisak/rpn-signature:unstable tspisak/rpn-signature:latest
docker push tspisak/rpn-signature:latest
docker tag tspisak/rpn-signature:latest tspisak/rpn-signature:$CIRCLE_TAG
docker push tspisak/rpn-signature:$CIRCLE_TAG
fi
workflows:
version: 2
build_test_deploy:
jobs:
- build:
filters:
tags:
only: /.*/
- update_cache:
requires:
- build
filters:
branches:
ignore: /docs?\/.*/
tags:
only: /.*/
- deploy:
requires:
- build
filters:
tags:
only: /^v.*/