我不知道我错过了什么。我有一个docker image, 和一个docker compose文件。
我的目标是在Jenkins
我猜这个
volumes:
- .:/var/www/html
是问题的根源,但容器最后一个图像不应该已经有供应商目录吗?
Dockerfile
FROM quay/php-base:7.2.
COPY . /var/www/html
RUN curl -sS https://getcomposer.org/installer | php
RUN php composer.phar install
RUN rm composer.phar
EXPOSE 9000
CMD ["php-fpm"]
build.testing.yml
version: "3"
services:
phpfpm:
build:
context: .
dockerfile: Dockerfile
image: xxx-phpfpm:${GIT_COMMIT}
environment:
- APP_ENV=testing
volumes:
- .:/var/www/html
Jenkins 构建 shell 命令
printenv
echo $GIT_BRANCH
echo $GIT_COMMIT
docker-compose -f build.testing.yml up -d --build --remove-orphans
docker-compose -f build.testing.yml exec -T phpfpm bash build/phpunit.sh
phpunit.sh
#!/usr/bin/env bash
cd /var/www/html;
ls -la;
ls -la vendor;
ls -la vendor/bin;
php vendor/bin/phpunit;
exit $?
构建日志(最后几行)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.6.0)
phpunit/phpunit suggests installing ext-soap (*)
phpunit/phpunit suggests installing ext-xdebug (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0)
Generating optimized autoload files
Removing intermediate container 56245736b26b
---> 818e587ac18a
Step 6/8 : RUN rm composer.phar
---> Running in 5ccbffc37e05
Removing intermediate container 5ccbffc37e05
---> 086e88f369fc
Step 7/8 : EXPOSE 9000
---> Running in 1c10e32ba134
Removing intermediate container 1c10e32ba134
---> 84eb9cbc3477
Step 8/8 : CMD ["php-fpm"]
---> Running in b6381d9b0f9a
Removing intermediate container b6381d9b0f9a
---> 40b32fa81d5f
Successfully built 40b32fa81d5f
Successfully tagged xxx-phpfpm:aa01355d1e8ab6d0f3daf87fb8f1f3b1be3e45be
Recreating xxxmicroservicetesting_phpfpm_1 ...
Recreating xxxmicroservicetesting_phpfpm_1 ... done
+ docker-compose -f build.testing.yml exec -T phpfpm bash build/phpunit.sh
total 224
drwxrwxr-x 13 1002 1002 4096 Jul 29 19:35 .
drwxr-xr-x 1 root root 18 May 5 2018 ..
-rw-rw-r-- 1 1002 1002 213 Jul 26 15:38 .editorconfig
-rw-rw-r-- 1 1002 1002 388 Jul 26 15:38 .env.example
drwxrwxr-x 8 1002 1002 162 Jul 29 19:41 .git
-rw-rw-r-- 1 1002 1002 55 Jul 26 15:38 .gitignore
-rw-rw-r-- 1 1002 1002 71 Jul 26 15:38 .styleci.yml
-rw-rw-r-- 1 1002 1002 232 Jul 26 15:38 Dockerfile
-rw-rw-r-- 1 1002 1002 895 Jul 29 18:25 Jenkinsfile
drwxrwxr-x 16 1002 1002 240 Jul 26 15:38 app
-rw-rw-r-- 1 1002 1002 1094 Jul 26 15:38 artisan
drwxrwxr-x 2 1002 1002 21 Jul 26 15:38 bootstrap
drwxrwxr-x 2 1002 1002 24 Jul 29 19:41 build
-rw-rw-r-- 1 1002 1002 250 Jul 29 19:35 build.testing.yml
-rw-rw-r-- 1 1002 1002 1256 Jul 26 15:38 composer.json
-rw-rw-r-- 1 1002 1002 179335 Jul 26 15:38 composer.lock
drwxrwxr-x 2 1002 1002 45 Jul 26 15:38 config
drwxrwxr-x 5 1002 1002 54 Jul 26 15:38 database
-rw-rw-r-- 1 1002 1002 193 Jul 26 15:38 phpcs.xml
-rw-rw-r-- 1 1002 1002 924 Jul 26 15:38 phpunit.xml
drwxrwxr-x 2 1002 1002 40 Jul 26 15:38 public
drwxrwxr-x 3 1002 1002 19 Jul 26 15:38 resources
drwxrwxr-x 2 1002 1002 40 Jul 26 15:38 routes
drwxrwxr-x 5 1002 1002 46 Jul 26 15:38 storage
drwxrwxr-x 4 1002 1002 113 Jul 26 15:38 tests
ls: vendor: No such file or directory
ls: vendor/bin: No such file or directory
Could not open input file: vendor/bin/phpunit
Build step 'Execute shell' marked build as failure
Finished: FAILURE