diff options
author | 2018-08-30 19:35:24 +0200 | |
---|---|---|
committer | 2018-08-30 20:42:05 +0200 | |
commit | 5489bc670b936ee7732154e62688f085adfd5af8 (patch) | |
tree | 8af71eba292d7ea095ad3ee961a98b5984a5f9d3 | |
parent | Push site base image on CI. (diff) |
Add CI build script.
-rw-r--r-- | .gitlab-ci.yml | 13 | ||||
-rw-r--r-- | docker/base.Dockerfile | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/deploy-ci.sh | 24 |
3 files changed, 19 insertions, 19 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e026ce6..fe86b32c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,13 @@ -build: - image: docker - tags: docker +build base image: + image: docker:stable-git + script: + - sh scripts/deploy-ci.sh + tags: + - docker only: - master - script: - - scripts/deploy-ci.sh + - django + - django+add-gitlab-ci lint: image: pythondiscord/django-site-ci:latest diff --git a/docker/base.Dockerfile b/docker/base.Dockerfile index 7252598d..c90ee5dc 100644 --- a/docker/base.Dockerfile +++ b/docker/base.Dockerfile @@ -1,3 +1,4 @@ +# Base image used for building the site. FROM python:3.7-alpine RUN apk add python3-dev git libpq postgresql-dev gcc cmake autoconf automake musl-dev diff --git a/scripts/deploy-ci.sh b/scripts/deploy-ci.sh index 1bf8ce00..f5c965ca 100644..100755 --- a/scripts/deploy-ci.sh +++ b/scripts/deploy-ci.sh @@ -1,23 +1,19 @@ #!/bin/bash # Build and deploy on master branch -if [[ $CI_COMMIT_REF_SLUG == 'master' ]]; then - echo "Connecting to docker hub" - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin +echo "Connecting to docker hub" +echo "$GITLAB_DOCKER_PASSWORD" | docker login --username "$GITLAB_DOCKER_USERNAME" --password-stdin registry.gitlab.com - changed_lines=$(git diff HEAD~1 HEAD docker/base.Dockerfile | wc -l) +changed_lines=$(git diff HEAD~1 HEAD docker/base.Dockerfile | wc -l) - if [ $changed_lines != '0' ]; then - echo "base.Dockerfile was changed" +if [ $changed_lines != '0' ]; then + echo "base.Dockerfile was changed" - echo "Building CI container" - docker build -t pythondiscord/django-site-ci:latest -f docker/base.Dockerfile . + echo "Building CI container" + docker build -t registry.gitlab.com/python-discord/projects/site/django-base:latest -f docker/base.Dockerfile . - echo "Pushing image to Docker Hub" - docker push pythondiscord/django-site-ci:latest - else - echo "base.Dockerfile was not changed, not building" - fi + echo "Pushing image to GitLab registry" + docker push registry.gitlab.com/python-discord/projects/site/django-base:latest else - echo "Skipping CI Docker build" + echo "base.Dockerfile was not changed, not building" fi |