From fe57e5139fb8396e2b929998850710d73de587ff Mon Sep 17 00:00:00 2001
From: jp <jp+pleroma@supplntr.io>
Date: Tue, 14 Jan 2020 12:32:36 -0500
Subject: [PATCH 1/2] Remove cache from docker jobs. Split devlop and stable
 branches into their own jobs

---
 .gitlab-ci.yml | 43 +++++++++++++++++++++++++++++++++----------
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b34c7e98d..ba6e41aef 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,10 +6,6 @@ variables: &global_variables
   POSTGRES_PASSWORD: postgres
   DB_HOST: postgres
   MIX_ENV: test
-  DOCKER_DRIVER: overlay2
-  DOCKER_HOST: unix:///var/run/docker.sock
-  DOCKER_IMAGE: $CI_REGISTRY_IMAGE:latest
-  DOCKER_IMAGE_SHA: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
 
 cache: &global_cache_policy
   key: ${CI_COMMIT_REF_SLUG}
@@ -274,16 +270,43 @@ arm64-musl:
 docker:
   stage: docker
   image: docker:latest
-  tags:
-    - dind
+  cache: {}
+  variables: &docker-variables
+    DOCKER_DRIVER: overlay2
+    DOCKER_HOST: unix:///var/run/docker.sock
+    IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
+    IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
+    IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
+    IMAGE_TAG_LATEST_STABLE: $CI_REGISTRY_IMAGE:latest-stable
   before_script: &before-docker
     - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
     - export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
     - export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
   script:
-    - docker pull $DOCKER_IMAGE || true
-    - docker build --cache-from $DOCKER_IMAGE --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $DOCKER_IMAGE_SHA -t $DOCKER_IMAGE .
-    - docker push $DOCKER_IMAGE_SHA
-    - docker push $DOCKER_IMAGE
+    - docker pull $IMAGE_TAG_SLUG || true
+    - docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg                       BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST .
+    - docker push $IMAGE_TAG
+    - docker push $IMAGE_TAG_SLUG
+    - docker push $IMAGE_TAG_LATEST
+  tags:
+    - dind
   only:
     - develop
+    - features/docker-updates
+
+docker-stable:
+  stage: docker
+  image: docker:latest
+  cache: {}
+  variables: *docker-variables
+  before_script: *before-docker
+  script:
+    - docker pull $IMAGE_TAG_SLUG || true
+    - docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg                               BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST_STABLE .
+    - docker push $IMAGE_TAG
+    - docker push $IMAGE_TAG_SLUG
+    - docker push $IMAGE_TAG_LATEST_STABLE
+  tags:
+    - dind
+  only:
+    - stable

From 964d188a96f8d746b6d1c0ca06c9abc5bc682a11 Mon Sep 17 00:00:00 2001
From: jp <jp+pleroma@supplntr.io>
Date: Tue, 14 Jan 2020 12:43:28 -0500
Subject: [PATCH 2/2] Add allow_failure to docker jobs

---
 .gitlab-ci.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ba6e41aef..b47bfb598 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -282,6 +282,7 @@ docker:
     - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
     - export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
     - export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
+  allow_failure: true
   script:
     - docker pull $IMAGE_TAG_SLUG || true
     - docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg                       BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST .
@@ -292,7 +293,6 @@ docker:
     - dind
   only:
     - develop
-    - features/docker-updates
 
 docker-stable:
   stage: docker
@@ -300,6 +300,7 @@ docker-stable:
   cache: {}
   variables: *docker-variables
   before_script: *before-docker
+  allow_failure: true
   script:
     - docker pull $IMAGE_TAG_SLUG || true
     - docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg                               BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST_STABLE .