在 Windows 10 / Docker 部署 中,在全局配置中启用 阿里云 Composer 全量镜像

1、查看 Composer 的全局配置选项的列表。打开命令行窗口并执行如下命令:镜像地址为官方源地址。如图1

查看 Composer 的全局配置选项的列表。打开命令行窗口并执行如下命令:镜像地址为官方源地址。

图1

PS E:/wwwroot/pcs-api> composer config --global --list
[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https://packagist.phpcomposer.com
[process-timeout] 300
[use-include-path] false
[preferred-install] auto
[notify-on-install] true
[github-protocols] [https, ssh]
[vendor-dir] vendor (E:/wwwroot/pcs-api/vendor)
[bin-dir] {$vendor-dir}/bin (E:/wwwroot/pcs-api/vendor/bin)
[cache-dir] C:/Users/Administrator/AppData/Local/Composer
[data-dir] C:/Users/Administrator/AppData/Roaming/Composer
[cache-files-dir] {$cache-dir}/files (C:/Users/Administrator/AppData/Local/Composer/files)
[cache-repo-dir] {$cache-dir}/repo (C:/Users/Administrator/AppData/Local/Composer/repo)
[cache-vcs-dir] {$cache-dir}/vcs (C:/Users/Administrator/AppData/Local/Composer/vcs)
[cache-ttl] 15552000
[cache-files-ttl] 15552000
[cache-files-maxsize] 300MiB (314572800)
[bin-compat] auto
[discard-changes] false
[autoloader-suffix]
[sort-packages] false
[optimize-autoloader] false
[classmap-authoritative] false
[apcu-autoloader] false
[prepend-autoloader] true
[github-domains] [github.com]
[bitbucket-expose-hostname] true
[disable-tls] false
[secure-http] true
[cafile]
[capath]
[github-expose-hostname] true
[gitlab-domains] [gitlab.com]
[store-auths] prompt
[archive-format] tar
[archive-dir] .
[htaccess-protect] true
[home] C:/Users/Administrator/AppData/Roaming/Composer
[github-oauth.github.com] 3e868f4f7e6ff6691f1a2c7fe5e8dbd8a174650f

2、打开 阿里云 Composer 全量镜像 网址:https://developer.aliyun.com/composer

3、系统全局配置: 即将配置信息添加到 Composer 的全局配置文件 config.json 中。打开命令行窗口并执行如下命令:

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

4、在 Docker 部署 中,在全局配置中启用 阿里云 Composer 全量镜像,编辑文件 Dockerfile,如图3

在 Docker 部署 中,在全局配置中启用 阿里云 Composer 全量镜像,编辑文件 Dockerfile

图3

FROM registry-vpc.cn-beijing.aliyuncs.com/cmc/centos-nginx112-php72:0.1.7

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 && /
    sed -i 's/disable_functions = exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show/disable_functions = system,shell_exec,escapeshellarg,escapeshellcmd,dl,popen,show/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 && /
    composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ && /
    cd /sobey/www/pcs-api && /
    composer install

5、重新构建 Docker 镜像,执行过程更加快速与稳定。之前耗时 35 分钟,现在耗时 18 分钟,如图4、图5

之前耗时 35 分钟

图4

现在耗时 18 分钟

图5

 

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

(0)
上一篇 2022年4月29日
下一篇 2022年4月29日

相关推荐

发表回复

登录后才能评论