Skip to content

Commit

Permalink
Split the test and base container builds (#1438)
Browse files Browse the repository at this point in the history
* Split the test and base container builds

* Remove guard

* Remove dependency on pre-commit
  • Loading branch information
jmsmkn committed Jul 10, 2020
1 parent bea2cee commit 2661754
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 27 deletions.
40 changes: 26 additions & 14 deletions .github/workflows/ci.yml
Expand Up @@ -24,7 +24,6 @@ jobs:
run: pre-commit run --all-files

django-tests:
needs: [precommit]
runs-on: ubuntu-latest
steps:
- name: Set up Python ${{ env.PYTHON_VERSION }}
Expand All @@ -42,9 +41,9 @@ jobs:
echo ::set-env name=GIT_COMMIT_ID::$(git describe --always --dirty)
echo ::set-env name=GIT_BRANCH_NAME::$(echo ${{ github.ref }} | cut -d/ -f3- | sed "s/[^[:alnum:]]//g")
echo ::set-env name=DOCKER_GID::$(getent group docker | cut -d: -f3)
- name: Build the containers
- name: Build the test container
run: |
make build
make build_web_test
- name: Run the django tests
run: |
docker pull crccheck/hello-world
Expand All @@ -55,17 +54,8 @@ jobs:
codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Push the containers if we're on master
if: github.ref == 'refs/heads/master'
run: |
echo $DOCKER_PASSWORD | docker login --username $DOCKER_USER --password-stdin
make push
env:
DOCKER_USER: grandchallenge
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

docs:
needs: [precommit]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand All @@ -74,9 +64,9 @@ jobs:
echo ::set-env name=GIT_COMMIT_ID::$(git describe --always --dirty)
echo ::set-env name=GIT_BRANCH_NAME::$(echo ${{ github.ref }} | cut -d/ -f3- | sed "s/[^[:alnum:]]//g")
echo ::set-env name=DOCKER_GID::$(getent group docker | cut -d: -f3)
- name: Build the containers
- name: Build the test container
run: |
make build
make build_web_test
- name: Build the docs
run: |
make docs
Expand All @@ -86,3 +76,25 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html

deploy:
needs: [django-tests]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v1
- name: Set the environment
run: |
echo ::set-env name=GIT_COMMIT_ID::$(git describe --always --dirty)
echo ::set-env name=GIT_BRANCH_NAME::$(echo ${{ github.ref }} | cut -d/ -f3- | sed "s/[^[:alnum:]]//g")
echo ::set-env name=DOCKER_GID::$(getent group docker | cut -d: -f3)
- name: Build the distributable containers
run: |
make build
- name: Push the containers
run: |
echo $DOCKER_PASSWORD | docker login --username $DOCKER_USER --password-stdin
make push
env:
DOCKER_USER: grandchallenge
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
26 changes: 14 additions & 12 deletions Makefile
Expand Up @@ -4,16 +4,7 @@ PYTHON_VERSION = 3.8
GDCM_VERSION_TAG = 3.0.6
POETRY_HASH = $(shell shasum -a 512 poetry.lock | cut -c 1-8)

build_web:
@docker pull grandchallenge/web-base:$(PYTHON_VERSION)-$(GDCM_VERSION_TAG)-$(POETRY_HASH) || { \
docker build \
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
--build-arg GDCM_VERSION_TAG=$(GDCM_VERSION_TAG) \
--target base \
-t grandchallenge/web-base:$(PYTHON_VERSION)-$(GDCM_VERSION_TAG)-$(POETRY_HASH) \
-f dockerfiles/web-base/Dockerfile \
.; \
}
build_web_test:
@docker pull grandchallenge/web-test-base:$(PYTHON_VERSION)-$(GDCM_VERSION_TAG)-$(POETRY_HASH) || { \
docker build \
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
Expand All @@ -33,6 +24,17 @@ build_web:
-t grandchallenge/web-test:latest \
-f dockerfiles/web/Dockerfile \
.

build_web_dist:
@docker pull grandchallenge/web-base:$(PYTHON_VERSION)-$(GDCM_VERSION_TAG)-$(POETRY_HASH) || { \
docker build \
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
--build-arg GDCM_VERSION_TAG=$(GDCM_VERSION_TAG) \
--target base \
-t grandchallenge/web-base:$(PYTHON_VERSION)-$(GDCM_VERSION_TAG)-$(POETRY_HASH) \
-f dockerfiles/web-base/Dockerfile \
.; \
}
docker build \
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
--build-arg GDCM_VERSION_TAG=$(GDCM_VERSION_TAG) \
Expand All @@ -50,8 +52,6 @@ build_http:
-t grandchallenge/http:latest \
dockerfiles/http

build: build_web build_http

push_web_base:
docker push grandchallenge/web-base:$(PYTHON_VERSION)-$(GDCM_VERSION_TAG)-$(POETRY_HASH)

Expand All @@ -66,6 +66,8 @@ push_http:
docker push grandchallenge/http:$(GIT_COMMIT_ID)-$(GIT_BRANCH_NAME)-$(POETRY_HASH)
docker push grandchallenge/http:latest

build: build_web_test build_web_dist build_http

push: push_web_base push_web_test_base push_web push_http

migrations:
Expand Down
3 changes: 2 additions & 1 deletion cycle_docker_compose.sh
Expand Up @@ -8,7 +8,8 @@ export GIT_COMMIT_ID=$(git describe --always --dirty)
export GIT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD | sed "s/[^[:alnum:]]//g")
export DOCKER_GID=$(getent group docker | cut -d: -f3)

make build
make build_web_test
make build_http

trap 'docker-compose down ; echo Stopped ; exit 0' SIGINT

Expand Down

0 comments on commit 2661754

Please sign in to comment.