From 7c1773a6940bff5e7447cbc4ae8c7733db75e836 Mon Sep 17 00:00:00 2001
From: Pernille Welle-Watne <perniww@online.no>
Date: Mon, 22 Feb 2021 13:55:53 +0100
Subject: [PATCH] Fix .gitlab-ci.yml file

---
 .gitlab-ci.yml | 47 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 44 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6907496..7326fca 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,9 +1,50 @@
-variables:
-  HEROKU_APP_NAME: <APP_NAME>
-
 stages:
+  - build
+  - test
   - deploy
 
+variables:
+  IMAGE: ${CI_REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}
+  HEROKU_APP_NAME: safe-meadow-86842
+
+build:
+  stage: build
+  image: docker:stable
+  services:
+    - docker:dind
+  variables:
+    DOCKER_DRIVER: overlay2
+  script:
+    - docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
+    - docker pull $IMAGE:build-python || true
+    - docker pull $IMAGE:production || true
+    - docker build
+      --target build-python
+      --cache-from $IMAGE:build-python
+      --tag $IMAGE:build-python
+      --file ./Dockerfile
+      "."
+    - docker build
+      --cache-from $IMAGE:production
+      --tag $IMAGE:production
+      --file ./Dockerfile
+      "."
+    - docker push $IMAGE:build-python
+    - docker push $IMAGE:production
+
+test:
+  stage: test
+  image: $IMAGE:production
+  services:
+    - postgres:latest
+  variables:
+    POSTGRES_DB: test
+    POSTGRES_USER: runner
+    POSTGRES_PASSWORD: ""
+    DATABASE_URL: postgres://runner@postgres:5432/test
+  script:
+    - python manage.py test
+
 deploy:
   stage: deploy
   script:
-- 
GitLab