Skip to content

Commit

Permalink
use specific tags in dockerfiles, clean up docker containers afterwards
Browse files Browse the repository at this point in the history
  • Loading branch information
hillalex committed Jul 14, 2020
1 parent cc626b9 commit 1ab7314
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 21 deletions.
1 change: 0 additions & 1 deletion buildkite/common
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ else
fi

BUILD_ENV_TAG=$ORG/montagu-portal-shared-build-env:$GIT_SHA
BUILD_ENV_NAME=montagu-portal-shared-build-env
8 changes: 4 additions & 4 deletions buildkite/make-integration-tests-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ TAG_BRANCH=$NAME:$GIT_BRANCH
# In case we switch agents between steps
[ ! -z $(docker images -q $BUILD_ENV_TAG) ] || docker pull $BUILD_ENV_TAG

# We build a docker image that inherits from the latest build env image
# so here tag the image with the name used in the dockerfile
docker tag $BUILD_ENV_TAG $BUILD_ENV_NAME
docker build -f ./docker/integration-tests.dockerfile \
-t $TAG_SHA \
--build-arg MONTAGU_GIT_ID=$GIT_SHA \
.

docker build -f ./docker/integration-tests.dockerfile -t $TAG_SHA .
docker tag $TAG_SHA $TAG_BRANCH
docker push $TAG_SHA
docker push $TAG_BRANCH
6 changes: 6 additions & 0 deletions buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ steps:

- label: ":construction_worker: Build and push integration test image"
command: buildkite/make-integration-tests-image.sh

- wait

- label: ":hammer: Stop dependencies"
command: app/scripts/clear-docker.sh
allow_dependency_failure: true
10 changes: 3 additions & 7 deletions buildkite/run-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@ set -ex
HERE=$(dirname $0)
. $HERE/common

PORTAL_BUILD_ENV=montagu-portal-build-env
PORTAL_BUILD_ENV=montagu-portal-build-env:$GIT_SHA

./$HERE/../app/scripts/run-dependencies.sh
./$HERE/../app/scripts/add-test-accounts-for-integration-tests.sh

# In case we switch agents between steps
[ ! -z $(docker images -q $BUILD_ENV_TAG) ] || docker pull $BUILD_ENV_TAG

# We build a docker image that inherits from the latest build env image
# so here tag the image with the name used in the dockerfile
docker tag $BUILD_ENV_TAG $BUILD_ENV_NAME

# The main build env which builds and tests below
docker build -f ./docker/build.dockerfile \
-t $PORTAL_BUILD_ENV:$GIT_SHA \
-t $PORTAL_BUILD_ENV \
--build-arg MONTAGU_GIT_ID=$GIT_SHA \
--build-arg MONTAGU_GIT_BRANCH=$GIT_BRANCH \
.
Expand All @@ -30,4 +26,4 @@ docker run \
-v $docker_auth_path:/root/.docker/config.json \
-v /var/run/docker.sock:/var/run/docker.sock \
--network=host \
$PORTAL_BUILD_ENV:$GIT_SHA
$PORTAL_BUILD_ENV
14 changes: 7 additions & 7 deletions docker/build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

git_branch=$1
git_id=$2
registry=docker.montagu.dide.ic.ac.uk:5000
org=vimc
contrib_name=montagu-contrib-portal
admin_name=montagu-admin-portal

Expand All @@ -26,8 +26,8 @@ function build {
app_name=$2
echo "Building $app_name portal image"
docker build -f docker/run.dockerfile \
-t $registry/$image_name:$git_id \
-t $registry/$image_name:$git_branch \
-t $org/$image_name:$git_id \
-t $org/$image_name:$git_branch \
--build-arg APP_NAME=$app_name \
.
}
Expand All @@ -41,7 +41,7 @@ function push {
docker push $id
}

push $registry/$contrib_name:$git_id
push $registry/$contrib_name:$git_branch
push $registry/$admin_name:$git_id
push $registry/$admin_name:$git_branch
push $org/$contrib_name:$git_id
push $org/$contrib_name:$git_branch
push $org/$admin_name:$git_id
push $org/$admin_name:$git_branch
3 changes: 2 additions & 1 deletion docker/build.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM montagu-portal-shared-build-env
ARG MONTAGU_GIT_ID="UNKNOWN"
FROM vimc/montagu-portal-shared-build-env:$MONTAGU_GIT_ID

ARG MONTAGU_GIT_ID="UNKNOWN"
ARG MONTAGU_GIT_BRANCH="UNKNOWN"
Expand Down
4 changes: 3 additions & 1 deletion docker/integration-tests.dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FROM montagu-portal-shared-build-env
ARG MONTAGU_GIT_ID="UNKNOWN"

FROM vimc/montagu-portal-shared-build-env:$MONTAGU_GIT_ID

ENTRYPOINT ["./scripts/run-integration-tests-in-container.sh"]

0 comments on commit 1ab7314

Please sign in to comment.