From f39aa9b82b96c89330403eda1a9600128370afa7 Mon Sep 17 00:00:00 2001
From: Benjamin GUILLON <benjamin.guillon@cc.in2p3.fr>
Date: Thu, 2 Apr 2020 19:11:04 +0200
Subject: [PATCH] Update .gitlab-ci.yml

---
 .gitlab-ci.yml | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b0438c7a..1ad55086 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,15 +7,14 @@ default:
   services:
   - docker:dind
   image: docker:latest
+  before_script:
+    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
 
 build:
   stage: build
-  before_script:
-    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
   script:
     - docker build --pull -t "$CI_REGISTRY_IMAGE/php-build:$CI_COMMIT_REF_SLUG" -f ./docker/php-build/Dockerfile . 
-    - docker create --name php-build-tmp "$CI_REGISTRY_IMAGE/php-build:$CI_COMMIT_REF_SLUG"
-    - docker cp php-build-tmp:/var/www/html "$CI_BUILD_DIR/php-build"
+    - docker cp $(docker create "$CI_REGISTRY_IMAGE/php-build:$CI_COMMIT_REF_SLUG"):/var/www/html "$CI_BUILD_DIR/php-build"
     - ls -la "$CI_BUILD_DIR/php-build"
     - docker rm -f php-build-tmp
   artifacts:
@@ -40,13 +39,11 @@ nginx-image-build:
 
 test:
   stage: test
-  image: $CI_REGISTRY_IMAGE/php-fpm:$CI_COMMIT_REF_SLUG
   variables:
     # Don't clone, the software is already in the image run
     GIT_STRATEGY: none 
   dependencies: []
   script:
-    - pwd && ls -la .
-    - sh ./tms/vendor/bin/simple-phpunit --configuration phpunit.xml.dist
+    - docker run $CI_REGISTRY_IMAGE/php-fpm:$CI_COMMIT_REF_SLUG sh ./tms/vendor/bin/simple-phpunit --configuration phpunit.xml.dist
   ## TODO: Define unit tests
   ## TODO: Add unit tests report as job artifact
-- 
GitLab