diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8ca25820ca8a8d562a71858eca13ad287c2f746e..a5ca2d3c9cf936e6f5bf2fc1c64623a605014f40 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,7 +1,15 @@
-build_image:
-  script:
-    - docker build -t gitlab-registry.cern.ch/chweber/zx_postprocessingplotter:zx_limit_container . 
-    - docker push gitlab-registry.cern.ch/chweber/zx_postprocessingplotter:zx_limit_container_test
+stages:
+    - build
+    - pipeline
+
+build zx_postprocessingplotter:
+    image: 
+        name: gitlab-registry.cern.ch/ci-tools/docker-image-builder
+        entrypoint: [""]
+    stage: build
+    variables: 
+        GIT_SUBMODULE_STRATEGY: recursive
+    script:
+        - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
+        - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
 
-  tags:
-    - docker-image-build # we need a ci runner that has the special docker image building ability
diff --git a/Dockerfile b/Dockerfile
index 75c927c3de98b71bf966ce71f8373df2192b8c6a..920113b2590ef08d3fa13d151eb283c9cddc325e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,13 +15,12 @@
 
 FROM atlas/athanalysis:21.2.94 AS centosContainer
 
-
-WORKDIR /workdir
+ARG PROJECT=workdir
 
 #ARG CACHEBUST=1 # with this the command below will run without cache
-RUN git clone https://gitlab.cern.ch/chweber/ZX_PostProcessingPlotter.git
-
+COPY . /$PROJECT/ZX_PostProcessingPlotter/
+#RUN sudo yum install -y vim
 
-WORKDIR /workdir
+WORKDIR /$PROJECT
 
 
diff --git a/limitSetting/limitSetting.py b/limitSetting/limitSetting.py
index ed76399726b214e2e49d4ecd2efa67d3b3e1b1c9..40f0999d25c5c6da4539cf6d09f5001e0309715a 100644
--- a/limitSetting/limitSetting.py
+++ b/limitSetting/limitSetting.py
@@ -835,6 +835,22 @@ def writeLimitsToCSV( limitDict ):
         writer.writerow(headerList)
         for csvLine in csvMetaList: writer.writerow(csvLine)
 
+
+    limit = 0
+    with open ('limits.csv') as f:
+        reader = csv.DictReader(f)
+        for row in reader:
+            for (k,v) in row.items():
+                if k == 'bestEstimate':
+                    limit = float(v)
+    import json
+    import numpy as np
+    result = {}
+    with open('output.json', 'w') as f:
+        result['loss'] = np.square(limit-1) # assuming limit is in fb, this is to find out the parameters that gives close limit to 1fb
+        print(result)
+        json.dump(result, f, indent=2)
+
     return None