From 7a1d0ccc40280e67ae43ee46db35b0581b312e79 Mon Sep 17 00:00:00 2001 From: Pernille Welle-Watne <perniww@online.no> Date: Mon, 22 Feb 2021 18:18:07 +0100 Subject: [PATCH] change type --- .gitlab-ci.yml | 37 ++++++++++++++++++++----------------- heruko.yml | 5 ----- release.sh | 11 +++++++++++ 3 files changed, 31 insertions(+), 22 deletions(-) delete mode 100644 heruko.yml create mode 100644 release.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 54bb1255..dd7869a8 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 3558175b..00000000 --- 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 00000000..19ebb5a8 --- /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 -- GitLab