diff options
Diffstat (limited to '')
-rw-r--r-- | .gitlab-ci.yml | 24 | ||||
-rw-r--r-- | docker/ci.Dockerfile | 21 | ||||
-rw-r--r-- | scripts/deploy-ci.sh | 23 |
3 files changed, 54 insertions, 14 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 595cbbdf..69625120 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,9 +5,33 @@ variables: RETHINKDB_HOST: rethinkdb stages: + - build - test - deploy +build: + before_script: + - docker info + + image: docker:stable + + only: + - master + + services: + - docker:dind + + stage: build + + script: + - sh scripts/deploy-ci.sh + + tags: + - docker + + variables: + DOCKER_DRIVER: overlay2 + test: tags: - docker diff --git a/docker/ci.Dockerfile b/docker/ci.Dockerfile index 3771e52b..0ea9ff9a 100644 --- a/docker/ci.Dockerfile +++ b/docker/ci.Dockerfile @@ -1,21 +1,14 @@ FROM python:3.6-alpine3.7 -RUN apk add --update tini \ - git \ +RUN apk add --update autoconf automake \ build-base \ - gcc \ - cmake \ - autoconf \ - automake \ - libtool \ - ruby \ - ruby-dev \ - ruby-rdoc \ - ruby-irb \ + cmake curl \ docker \ - curl \ - nodejs \ - nodejs-npm + gcc git \ + libtool \ + nodejs nodejs-npm + ruby ruby-dev ruby-irb ruby-rdoc \ + tini ENV PIPENV_VENV_IN_PROJECT=1 ENV PIPENV_IGNORE_VIRTUALENVS=1 diff --git a/scripts/deploy-ci.sh b/scripts/deploy-ci.sh new file mode 100644 index 00000000..6a3d64bc --- /dev/null +++ b/scripts/deploy-ci.sh @@ -0,0 +1,23 @@ +#!/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 + + changed_lines=$(git diff HEAD~1 HEAD docker/ci.Dockerfile | wc -l) + + if [ $changed_lines != '0' ]; then + echo "ci.Dockerfile was changed" + + echo "Building CI container" + docker build -t pythondiscord/site-ci:latest -f docker/ci.Dockerfile . + + echo "Pushing image to Docker Hub" + docker push pythondiscord/site-ci:latest + else + echo "ci.Dockerfile was not changed, not building" + fi +else + echo "Skipping CI Docker build" +fi |