Build docker container in CI

For tags, we'll also push and tag that container.
parent 8f875bfd
...@@ -13,13 +13,19 @@ variables: ...@@ -13,13 +13,19 @@ variables:
PY36_IMAGE: thalia/python-thalia:3.6 PY36_IMAGE: thalia/python-thalia:3.6
PIP_CACHE_DIR: "${CI_PROJECT_DIR}/pip-cache" PIP_CACHE_DIR: "${CI_PROJECT_DIR}/pip-cache"
stages:
- test
- deploy
pep8: pep8:
stage: test
image: $PY35_IMAGE image: $PY35_IMAGE
before_script: before_script:
script: script:
- tox -e flake8 - tox -e flake8
.djangotest: &djangotest .djangotest: &djangotest
stage: test
services: services:
- postgres:latest - postgres:latest
before_script: before_script:
...@@ -44,6 +50,7 @@ python36-django20: ...@@ -44,6 +50,7 @@ python36-django20:
DJANGO_VERSION: django20 DJANGO_VERSION: django20
docs: docs:
stage: test
image: $PY35_IMAGE image: $PY35_IMAGE
before_script: before_script:
# install django deps # install django deps
...@@ -60,6 +67,45 @@ docs: ...@@ -60,6 +67,45 @@ docs:
- ./generate-apidocs.sh - ./generate-apidocs.sh
- git diff --exit-code - git diff --exit-code
build docker image:
stage: test
services:
- docker:dind
image: thalia/docker-compose
tags:
- docker
before_script:
- echo $GITLAB_REGISTRY_PASSWORD | docker login --username thaliawww --password-stdin registry.gitlab.com
script:
- docker-compose build --build-arg install_dev_requirements=0 web
- docker-compose run --rm web test
- docker tag $DOCKER_LATEST $DOCKER_TAG
- docker push $DOCKER_TAG
variables:
DOCKER_LATEST: registry.gitlab.com/thaliawww/concrexit:latest
DOCKER_TAG: registry.gitlab.com/thaliawww/concrexit:$CI_COMMIT_SHA
tag docker image:
stage: deploy
services:
- docker:dind
image: docker:git
tags:
- docker
only:
- tags
dependencies:
- build docker image
before_script:
- echo $GITLAB_REGISTRY_PASSWORD | docker login --username thaliawww --password-stdin registry.gitlab.com
script:
- docker pull $DOCKER_TAG
- docker push $DOCKER_TAG_PRODUCTION
variables:
DOCKER_TAG: registry.gitlab.com/thaliawww/concrexit:$CI_COMMIT_SHA
DOCKER_TAG_PRODUCTION: registry.gitlab.com/thaliawww/concrexit:$CI_COMMIT_TAG
cache: cache:
key: "$CI_JOB_NAME" key: "$CI_JOB_NAME"
paths: paths:
......
...@@ -67,4 +67,4 @@ COPY docs /usr/src/app/docs ...@@ -67,4 +67,4 @@ COPY docs /usr/src/app/docs
# Cache docs between builds if not mounting to FS # Cache docs between builds if not mounting to FS
VOLUME /concrexit/docs VOLUME /concrexit/docs
RUN echo "Don't build releases without release.sh!" RUN echo "Don't build releases yourself, let CI do it!"
...@@ -42,6 +42,9 @@ version_major=${version%.*} ...@@ -42,6 +42,9 @@ version_major=${version%.*}
echo "Changing directory to root of repository" echo "Changing directory to root of repository"
cd "${0%/*}" cd "${0%/*}"
echo "Making sure we're up-to-date"
git fetch --tags
echo "Changing to branch 'release/$version_major'" echo "Changing to branch 'release/$version_major'"
git checkout "release/$version_major" git checkout "release/$version_major"
...@@ -57,23 +60,6 @@ fi ...@@ -57,23 +60,6 @@ fi
if yesno "Do you want to push the tag to the repository?"; then if yesno "Do you want to push the tag to the repository?"; then
echo "Pushing tags:" echo "Pushing tags:"
git push --tags git push --tags
echo "Don't forget to fill in the release description" echo "Don't forget to fill in the release description on the website:"
fi echo "https://gitlab.science.ru.nl/thalia/concrexit/tags/v$version/release/edit"
if ! yesno "Do you want to build a docker container?"; then
exit 1
fi
if [ -n "$(git status --porcelain)" ]; then
echo "Unclean working directory!"
git status
exit 1
fi
docker_tag="registry.gitlab.com/thaliawww/concrexit:$version"
docker build --build-arg install_dev_requirements=0 --pull -t "$docker_tag" .
if yesno "Do you want to push the container?"; then
docker push "$docker_tag"
fi fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment