PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

快速搭建composer内网代码仓库

藏色散人
藏色散人 转载
2021-08-03 15:14:39 2606浏览

下面由composer教程栏目给大家介绍docker怎么搭建内网composer satis代码仓库,希望对需要的朋友有所帮助!

搭建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指定去哪获取包
require指定获取哪些包,如果想获取所有包,使用require-all: true
archive.directoryoutput-dir 即使build的输出目录
archive.format可选,默认:zip, 支持两种压缩格式:zip,tar。build时采用的压缩格式
archive.skip-dev可选,默认情况下为false,启用时(true)satis不会为分支机构创建下载
archive.prefix-url可选的下载位置,主页(来自satis.json),默认情况下是目录
官网说明:https://docs.phpcomposer.com/articles/handling-private-packages-with-satis.html
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;
        }
}

593fd9e56dd375e338137968cb686c4.png

声明:本文转载于:segmentfault,如有侵犯,请联系admin@php.cn删除