forked from singularityhub/docker2singularity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
175 lines (151 loc) · 4.58 KB
/
config.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# This is a continuous build CircleCI configuration for a Docker container
# intended to bulid on CircleCI to spread out testing over Travis/Circle.
# The container is built and pushed to the CONTAINER_NAME variable
# defined here or within the CircleCI settings. The following environment
# variables are acceptable here or in these settings (for sensitive information)
#
# CONTAINER_NAME
# DOCKER_USER
# DOCKER_EMAIL
################################################################################
# Functions
################################################################################
# Defaults
defaults: &defaults
docker:
- image: docker:18.01.0-ce-git
working_directory: /tmp/src
environment:
- CONTAINER_NAME: singularityware/docker2singularity
# Installation
install: &install
name: Install parallel gzip, gettext, python3, and jq
command: apk add --no-cache pigz python3 gettext jq
dockerload: &dockerload
name: Load Docker container Image
no_output_timeout: 30m
command: |
echo "Working directory is ${PWD}"
docker info
set +o pipefail
if [ -f /tmp/cache/container.tar.gz ]; then
apk update && apk add --no-cache pigz curl curl-dev
pigz -d --stdout /tmp/cache/container.tar.gz | docker load
fi
dockersave: &dockersave
name: Docker Save
no_output_timeout: 40m
command: |
DOCKER_TAG="v$(cat VERSION)"
echo "Saving ${CONTAINER_NAME}:${DOCKER_TAG} to container.tar.gz"
mkdir -p /tmp/cache
docker save ${CONTAINER_NAME}:${DOCKER_TAG} \
| pigz -2 -p 3 > /tmp/cache/container.tar.gz
dockerdeploy: &dockerdeploy
name: Deploy to Docker Hub
no_output_timeout: 40m
command: |
docker images
DOCKER_TAG="v$(cat VERSION)"
echo "Container name set to ${CONTAINER_NAME}:${DOCKER_TAG}"
if [[ -n "$DOCKER_PASS" ]]; then
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker push ${CONTAINER_NAME}:${DOCKER_TAG}
echo "Tagging latest image..."
docker tag ${CONTAINER_NAME}:${DOCKER_TAG} ${CONTAINER_NAME}:latest
docker push ${CONTAINER_NAME}:latest
fi
dockerbuild: &dockerbuild
name: Build development Docker container
command: |
echo "Building base image..."
DOCKER_TAG="v$(cat VERSION)"
docker build -t ${CONTAINER_NAME}:${DOCKER_TAG} .
test: &test
name: Test using docker2singularity
command: |
echo "Testing docker2singularity entrypoint"
DOCKER_TAG="v$(cat VERSION)"
echo "1. Testing run without arguments..."
echo "docker run ${CONTAINER_NAME}:${DOCKER_TAG}"
docker run "${CONTAINER_NAME}:${DOCKER_TAG}"
echo "Return value $?"
################################################################################
# Jobs
################################################################################
version: 2
jobs:
build:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- docker-v1-{{ .Branch }}
paths:
- /tmp/cache/container.tar.gz
- restore_cache:
key: dependency-cache
- setup_remote_docker
- run: *install
- run: *dockerload
- run: *dockerbuild
- run: *test
- run: *dockersave
- persist_to_workspace:
root: /tmp
paths:
- src
- cache
update_cache:
<<: *defaults
steps:
- attach_workspace:
at: /tmp
- save_cache:
key: docker-v1-{{ .Branch }}
paths:
- /tmp/cache/container.tar.gz
deploy:
<<: *defaults
steps:
- attach_workspace:
at: /tmp
- setup_remote_docker
- run: *dockerload
- run: *dockerdeploy
################################################################################
# Workflows
################################################################################
workflows:
version: 2
build_test_deploy:
jobs:
- build:
filters:
branches:
ignore:
- gh-pages
- /docs?/.*/
tags:
only: /.*/
- update_cache:
requires:
- build
filters:
branches:
ignore:
- gh-pages
- /docs?/.*/
tags:
only: /.*/
# Upload the container to Docker Hub
- deploy:
requires:
- build
- update_cache
filters:
branches:
only: master
tags:
only: /.*/