没有不值得去解决的问题,也没有不值得去学习的技术!

Fixing the ‘composer install’ Returned a Non-Zero Code: 255 Error During Jenkins Builds

Detailed error information when building with Jenkins

1. The Dockerfile code is as follows:

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. When building with Jenkins, the detailed error information is as follows, as shown in Figure 1.

Detailed error information when building with Jenkins
Figure 1
Plaintext

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. Edit the Dockerfile to temporarily remove the composer-related steps. After the build succeeds, running composer -V in the Docker container yields no response, as shown in Figure 2.

Edit the Dockerfile to temporarily remove the composer-related steps. After the build succeeds, running composer -V in the Docker container yields no response
Figure 2
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

4. Edit the Dockerfile to modify the configuration in php.ini: open_basedir (add the directory tree /usr/local/php/ that PHP is allowed to open) and allow_url_fopen, as shown in Figure 3.

Edit the Dockerfile to modify the configuration in php.ini: open_basedir (add the directory tree /usr/local/php/ that PHP is allowed to open) and allow_url_fopen
Figure 3
Dockerfile

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. When building with Jenkins, the result meets expectations, as shown in Figure 4.

When building with Jenkins, the result meets expectations
Figure 4

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系