diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 54bb12558af5313050351922bf046657098ffa4d..dd7869a8f5727525364eb716d752bbce38e18703 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,9 @@ variables: HEROKU_APP_NAME: tdt4242-base + HEROKU_REGISTRY_IMAGE: registry.heroku.com/${HEROKU_APP_NAME}/web -image: python:3 test: + image: python:3 script: # this configures Django application to use attached postgres database that is run on `postgres` host - cd backend/secfit @@ -10,22 +11,24 @@ test: - pip install -r requirements.txt - python manage.py test -staging: - stage: staging - script: - - echo “Deploying the app†- - pip install docker-compose - - docker-compose build - - docker-compose up -d +image: docker:stable +services: + - docker:dind +stages: + - build_and_deploy -development: - type: deploy - image: ruby +build_and_deploy: + stage: build_and_deploy script: - - apt-get update -qy - - apt-get install -y ruby-dev - - gem install dpl - - dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_AUTH_TOKEN - only: - - master + - apk add --no-cache curl + - docker login -u _ -p $HEROKU_AUTH_TOKEN registry.heroku.com + - docker pull $HEROKU_REGISTRY_IMAGE || true + - docker build + --cache-from $HEROKU_REGISTRY_IMAGE + --tag $HEROKU_REGISTRY_IMAGE + --file ./Dockerfile + "." + - docker push $HEROKU_REGISTRY_IMAGE + - chmod +x ./release.sh + - ./release.sh \ No newline at end of file diff --git a/heruko.yml b/heruko.yml deleted file mode 100644 index 3558175bc9696f51569ae2c4c96c9f056a417365..0000000000000000000000000000000000000000 --- a/heruko.yml +++ /dev/null @@ -1,5 +0,0 @@ -build: - docker: - web: Dockerfile - run: - - web: docker-compose build && docker-compose up -d diff --git a/release.sh b/release.sh new file mode 100644 index 0000000000000000000000000000000000000000..19ebb5a890dd92982ee6f3826240dcb7e380630c --- /dev/null +++ b/release.sh @@ -0,0 +1,11 @@ +#!/bin/sh + + +IMAGE_ID=$(docker inspect ${HEROKU_REGISTRY_IMAGE} --format={{.Id}}) +PAYLOAD='{"updates": [{"type": "web", "docker_image": "'"$IMAGE_ID"'"}]}' + +curl -n -X PATCH https://api.heroku.com/apps/$HEROKU_APP_NAME/formation \ + -d "${PAYLOAD}" \ + -H "Content-Type: application/json" \ + -H "Accept: application/vnd.heroku+json; version=3.docker-releases" \ + -H "Authorization: Bearer ${HEROKU_AUTH_TOKEN}" \ No newline at end of file