首頁  >  文章  >  開發工具  >  快速搭建composer內網代碼倉庫

快速搭建composer內網代碼倉庫

藏色散人
藏色散人轉載
2021-08-03 15:14:392828瀏覽

下面由composer教學專欄來介紹Docker如何搭建內網composer satis程式碼倉庫,希望對需要的朋友有幫助!

快速搭建composer內網代碼倉庫

建置composer內網程式碼倉庫

拉取composer/satis 映像

docker pull composer/satis

設定composer

##該步驟可跳過
#目錄結構

├── auth.json
├── cache
│   ├── files
│   ├── repo
│   └── vcs
├── composer.json
└── config.json

composer.json

{
}

config.json

{
    "config": {
        "secure-http": false,
        "optimize-autoloader": false,
        "preferred-install": "dist",
        "sort-packages": true,
        "platform": {
        }
    },
    "repositories": {
        "packagist": {
            "type": "composer",
            "url": "https://mirrors.aliyun.com/composer/"
        }
    }
}

建置模組擴充##目錄結構

├── config.json
├── public
│   ├── dist
│   │   ├── bpc
│   │   └── zhanghuizong
│   ├── include
│   │   └── all$f3811758e4611a4dfc1a96f4d1c06da09cdbe199.json
│   ├── index.html
│   └── packages.json
└── satis.sh

config.json

{
    "name": "composer_satis_test",
    "homepage": "http://local.satis.com",
    "repositories": [
        {
            "type": "git",
            "name": "zhanghuizong/composer_satis_test",
            "url": "https://gitee.com/zhanghuizong/composer_satis_test.git"
        }
    ],
    "require": {
        "zhanghuizong/composer_satis_test": "*"
    },
    "archive": {
        "directory": "dist",
        "format": "tar",
        "skip-dev": true,
        "prefix-url": "http://local.satis.com"
    }
}

關鍵字repositories requirearchive.directoryarchive.formatarchive.skip-devarchive.prefix-url#官網說明:https://docs.phpcomposer.com/articles/handling-private-packages-with-satis.html
#描述
指定去哪裡獲取包
#指定要取得哪些包,如果想要取得所有包,使用require-all: true
output-dir 即使build的輸出目錄
可選,預設:zip, 支援兩種壓縮格式:zip,tar。 build時採用的壓縮格式
可選,預設為false,啟用時(true)satis不會為分支機構創建下載
可選的下載位置,首頁(來自satis.json),預設為目錄
GitHub程式碼:https://github.com/composer/ satis

shell 腳本

satis.sh

#!/usr/bin/env bash

docker run --rm --init -it -v "$(pwd)"/config.json:/satis.json:ro \
-v "$(pwd)"/public/:/build \
-v /mnt/d/workspaces/docker-config/composer/:/composer \
composer/satis build /satis.json /build "$@"

增加快速存取

編輯檔案:vi ~/.bashrc

alias satis='docker run --rm --init -it -v "$(pwd)"/config.json:/satis.json:ro -v "$(pwd)"/public/:/build -v /mnt/d/workspaces/docker-config/composer/:/composer composer/satis build /satis.json /build'

用法

# 构建所有代码仓库模块
sh satis.sh

# 安装指定模块
sh satis.sh zhanghuizong/composer_satis_test

注意

指定模組安裝,repositories 節點中必須配置name 字段,同時與require 節點配置對應上

nginx 配置

server {
        listen        80;
        server_name  local.satis.com;
        root   "/data/httpd/docker-config/composer_satis/test/public/";
        location / {
            index index.php index.html;
        }

        location ~ \.php(.*)$ {
            fastcgi_pass   php:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

快速搭建composer內網代碼倉庫

以上是快速搭建composer內網代碼倉庫的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:segmentfault.com。如有侵權,請聯絡admin@php.cn刪除