Olivier Massot 7 months ago
parent
commit
7ddeffe0a9
2 changed files with 32 additions and 18 deletions
  1. 13 18
      .gitlab-ci.yml
  2. 19 0
      Dockerfile

+ 13 - 18
.gitlab-ci.yml

@@ -1,39 +1,34 @@
 stages:
+  - build
   - test
 
-before_script:
-  - apt-get -yqq update
-  - apt-get -yqq install zip unzip libexif-dev
-  - docker-php-ext-install exif
-  - docker-php-ext-enable exif
-  - curl -sS https://composer.github.io/installer.sig > installer.sig
-  - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
-  - php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
-  - php composer-setup.php
-  - php -r "unlink('composer-setup.php'); unlink('installer.sig');"
-  - pecl -q install xdebug-3.3.2
-  - docker-php-ext-enable xdebug
-  - echo zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so >> /usr/local/etc/php/conf.d/xdebug.ini
-  - echo xdebug.mode=coverage >> /usr/local/etc/php/conf.d/xdebug.ini
-
 cache:
   paths:
     - ./ot_core/.Build/vendor
 
+build_image:
+  stage: build
+  image: docker:20.10
+  before_script:
+    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
+  script:
+    - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
+    - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
+    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
+    - docker push $CI_REGISTRY_IMAGE:latest
+
 unit:otcore:
+  image: $CI_REGISTRY_IMAGE:latest
   stage: test
-
   script:
     - php composer.phar --no-interaction --working-dir=./ot_core install
     - ./ot_core/.Build/bin/phpunit -c ./ot_core/Tests/Build/UnitTests.xml --coverage-text --colors=never
-
   artifacts:
     paths:
       - ./ot_core/coverage/
     when: always
     reports:
       junit: ./ot_core/coverage/junit-report.xml
-
   coverage: '/^\s*Lines:\s*\d+.\d+\%/'
 
 

+ 19 - 0
Dockerfile

@@ -0,0 +1,19 @@
+FROM php:8.3-fpm
+
+# Installation des dépendances système
+RUN apt-get update && apt-get install -yqq --no-install-recommends \
+    zip unzip libexif-dev
+
+# Installation des extensions PHP
+RUN docker-php-ext-install exif && \
+    docker-php-ext-enable exif
+
+# Installation de Composer
+COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
+
+# Installation de xdebug
+RUN pecl -q install xdebug-3.3.2 && \
+    docker-php-ext-enable xdebug && \
+    echo zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so >> /usr/local/etc/php/conf.d/xdebug.ini && \
+    echo xdebug.mode=coverage >> /usr/local/etc/php/conf.d/xdebug.ini
+