lvxianchao / notes

狗屁不通瞎写的博客
https://coderlxc.com
1 stars 0 forks source link

搭建 Composer 私有仓库 #17

Open lvxianchao opened 2 years ago

lvxianchao commented 2 years ago
docker run --name nginx --restart always -p 80:80 -v /root/satis/build:/usr/share/nginx/html:ro -v /etc/nginx/conf.d/:/etc/nginx/conf.d/ -d nginx

https://github.com/composer/satis

https://learnku.com/articles/14856/composersatis-speed-up-composer-private-active

# 拷贝nginx 镜像中的 默认的 nginx 部分配置文件
docker run --name tmp-nginx-container -d nginx
docker cp tmp-nginx-container:/etc/nginx/conf.d/ /etc/nginx/conf.d/
docker rm -f tmp-nginx-container
lvxianchao commented 2 years ago
{
  "name": "my/composer",
  "homepage": "http://10.15.1.175:11000",
  "repositories": [
    { "type": "git", "url": "http://10.15.1.175:10000/php/test.git" }
  ],
  "require-all": false,
  "require-dependencies": true,
  "require-dev-dependencies": true,
  "require": {
    "php/test": "*"
  },
  "archive": {
    "directory": "dist",
    "format": "zip",
    "skip-dev": true
  },
  "config": {
    "secure-http": false
  }
}
lvxianchao commented 2 years ago

Your configuration does not allow connections to http://192.168.56.101/packages.json. See https://getcomposer.org/doc/06-config.md#secure-http for details.

composer config -g secure-http false
lvxianchao commented 2 years ago

Could not find a version of package simplexi/test matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability.

composer require xxxx/test:dev-main

image

lvxianchao commented 2 years ago
// Composer 私有源的名称,可随意
"name": "Easy Repository",

// 建立之后home页面的地址(用于查看这个源有哪些package)
"homepage": "http://packagist.satis.cc",

// 获取package的地址
/** 
  这里如果你是需要从私有的git源获取package的话,就参照如下这样写就可以了
  (带.git和不带.git似乎都ok)
  {"type": "vcs","url": "https://gitlab.local.com/aBigPackage/helloWorld"}

  如果你是需要构建内网的源,且内外网分离的情况下从外网获取package到内网,就参照下面这样写就好了
  (没有必要挨个去写需要引用的package的github地址)
  {"type": "composer", "url": "https://packagist.laravel-china.org"}
*/
"repositories": [
  {"type": "vcs","url": "https://gitlab.local.com/aBigPackage/helloWorld"},
  {"type": "composer", "url": "https://packagist.laravel-china.org"}
],

//如果需要satis将package下载到本地,直接从本地拉取,则需要配置这一项
//(内网源必须配置此项)
"archive": {
  "directory": "dist",

  //tar or zip
  "format": "tar",

  //是否需要为分支创建下载(默认只对有tag的提交创建下载)
  "skip-dev": false,
  "prefix-url": "http://packagist.satis.cc"
},

// 被抛弃或替换的package
"abandoned":{
  //true表示这个 package 真正的被抛弃
  "lox/simpletest":true
  //表示 lastcraft/simpletest 被 simpletest/simpletest 替换
  "lastcraft/simpletest" : "simpletest/simpletest"
},

// 需要 satis 的全部的 package
"require":{
  "monolog/monolog": "*",
  "darkaonline/l5-swagger": "~5.4",
  "laravel/laravel":"~5.4",
  "league/flysystem-aws-s3-v3":"*",
  "zircote/swagger-php":"*",
  "simpletest/simpletest":"*"
},

//是否需要将配置的源的全部的package都拉取
"require-all": false,
//是否自动解决依赖
"require-dependencies": true
//是否自动解决dev依赖
"require-dev-dependencies": true