基于 Jenkins 构建时,报错:’composer install’ returned a non-zero code: 255 的解决

1、Dockerfile 的代码如下:

FROM registry-vpc.cn-beijing.aliyuncs.com/cmc/centos-nginx112-php71:0.2.4

MAINTAINER wjtester@sobey.com

COPY code /sobey/www/pcs-api
COPY code/build/c_files/ /

RUN chown -R nginx:nginx /sobey/www/ && /
    rm -rf /etc/nginx/conf.d/status.conf && /
    chmod +x /usr/local/bin/composer && /
    cd /sobey/www/pcs-api && /
    composer install

2、基于 Jenkins 构建时,报错详细信息如下,如图1

基于 Jenkins 构建时,报错详细信息如下

图1

Step 4 : COPY code/build/c_files/ /
 ---> f287879fb9ba
Removing intermediate container 8e0f70e90e2b
Step 5 : RUN chown -R nginx:nginx /sobey/www/ &&     rm -rf /etc/nginx/conf.d/status.conf &&     chmod +x /usr/local/bin/composer &&     cd /sobey/www/pcs-api &&     composer install --no-dev
 ---> Running in 0c4904881ff7
The command '/bin/sh -c chown -R nginx:nginx /sobey/www/ &&     rm -rf /etc/nginx/conf.d/status.conf &&     chmod +x /usr/local/bin/composer &&     cd /sobey/www/pcs-api &&     composer install --no-dev' returned a non-zero code: 255
Build step 'Docker Build and Publish' marked build as failure
Finished: FAILURE

3、编辑 Dockerfile,暂时取消 composer 相关,构建成功后,在 Docker 容器中运行 composer -V,无反应,如图2

编辑 Dockerfile,暂时取消 composer 相关,构建成功后,在 Docker 容器中运行 composer -V,无反应

图2

FROM registry-vpc.cn-beijing.aliyuncs.com/cmc/centos-nginx112-php71:0.2.4

MAINTAINER wjtester@sobey.com

COPY code /sobey/www/pcs-api
COPY code/build/c_files/ /

RUN chown -R nginx:nginx /sobey/www/ && /
    rm -rf /etc/nginx/conf.d/status.conf

4、编辑 Dockerfile,编辑 php.ini 中的配置:open_basedir(新增 PHP 所能打开的文件的目录树 /usr/local/php/)、allow_url_fopen,如图3

编辑 Dockerfile,编辑 php.ini 中的配置:open_basedir(新增 PHP 所能打开的文件的目录树 /usr/local/php/)、allow_url_fopen

图3

FROM registry-vpc.cn-beijing.aliyuncs.com/cmc/centos-nginx112-php71:0.2.4

MAINTAINER wjtester@sobey.com

RUN sed -i 's/open_basedir = .//://sobey://tmp://data://webtv/;open_basedir = .//://sobey://tmp://data://webtv://usr//local//php/g' /usr/local/php/etc/php.ini && /
    sed -i 's/allow_url_fopen = Off/allow_url_fopen = On/g' /usr/local/php/etc/php.ini

COPY code /sobey/www/pcs-api
COPY code/build/c_files/ /

RUN chown -R nginx:nginx /sobey/www/ && /
    rm -rf /etc/nginx/conf.d/status.conf && /
    chmod +x /usr/local/bin/composer && /
    cd /sobey/www/pcs-api && /
    composer install

5、基于 Jenkins 构建时,符合预期,如图4

基于 Jenkins 构建时,符合预期

图4

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/181129.html

(0)
上一篇 2021年10月31日
下一篇 2021年10月31日

相关推荐

发表回复

登录后才能评论