Home  >  Article  >  Development Tools  >  Quickly build composer intranet code warehouse

Quickly build composer intranet code warehouse

藏色散人
藏色散人forward
2021-08-03 15:14:392860browse

The following column composer tutorial will introduce to you how to build an intranet composer satis code warehouse with Docker. I hope it will be helpful to friends in need!

Quickly build composer intranet code warehouse

Build composer intranet code warehouse

Pull composer/satis image

docker pull composer/satis

Configure composer

This step can be skipped

Directory structure

├── 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/"
        }
    }
}

Building module extension

Directory structure

├── 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"
    }
}
Keywords Description
repositories Specify where to get the package
require Specify which packages to get. If you want to get all packages, use require-all: true
archive.directory output-dir Even if the build output directory
archive.format is optional, Default: zip, supports two compression formats: zip, tar. The compression format used when building
archive.skip-dev Optional, false by default, when enabled (true) satis will not create branches for branches Download
archive.prefix-url Optional download location, homepage (from satis.json), by default directory
Official website description: https://docs.phpcomposer.com/articles/handling-private-packages-with-satis.html
GitHub code: https://github.com/composer/ satis

shell script

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 "$@"

Add quick access

Edit file: 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'

Usage

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

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

Note

Specify module installation, the name field must be configured in the repositories node, and correspond to the require node configuration

nginx configuration

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;
        }
}

Quickly build composer intranet code warehouse

The above is the detailed content of Quickly build composer intranet code warehouse. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete