Remove any created Docker volumes before and after build
@@ -147,13 +147,22 @@ jobs:
export ST2_GITREV=${CIRCLE_BRANCH}
.circle/buildenv_st2.sh
working_directory: ~/st2-packages
+ - run:
+ name: Pre Docker cleanup
+ command: |
+ set -x
+ # Clean-up running containers
+ .circle/docker-compose2.sh clean
+ # Remove st2-packages-vol container
+ docker rm -v --force st2-packages-vol || true
+ # Clean-up any created volumes
+ docker volume prune --force
+ working_directory: ~/st2-packages
- run:
# Workaround for CircleCI docker-compose limtation where volumes don't work
# See detailed explanation: https://circleci.com/docs/2.0/building-docker-images/#mounting-folders
name: Copy st2-packages files to build containers
command: |
- # Remove st2-packages-vol container if exists in CircleCI cache
- docker rm -f st2-packages-vol || true
# creating dummy container which will hold a volume with data files
docker create -v /root/st2-packages -v ${ST2_GITDIR} -v /root/build -v /var/log/st2 -v /root/.cache/pip -v /tmp/wheelhouse --name st2-packages-vol alpine:3.4 /bin/true
# copy st2-packages data files into this volume
@@ -187,13 +196,10 @@ jobs:
- run:
name: Test the Packages
command: |
- set +e
- .circle/docker-compose2.sh test ${DISTRO} || export TEST_FAILED=1
+ set -x
+ .circle/docker-compose2.sh test ${DISTRO}
# Once test container finishes we can copy logs directly from it
docker cp st2-packages-vol:/var/log/st2 ~/st2/packages/${DISTRO}/log/st2
- # Clean-up running containers
- .circle/docker-compose2.sh clean
- test -z "$TEST_FAILED"
working_directory: ~/st2-packages
- store_artifacts:
path: ~/st2/packages
@@ -202,6 +208,17 @@ jobs:
root: packages
paths:
- .
+ - run:
+ name: Post Docker cleanup
+ command: |
+ set -x
+ # Clean-up running containers
+ .circle/docker-compose2.sh clean
+ # Remove st2-packages-vol container
+ docker rm -v --force st2-packages-vol || true
+ # Clean-up any created volumes
+ docker volume prune --force
+ working_directory: ~/st2-packages
# Deploy produced deb/rpm packages to PackageCloud staging
deploy:
