日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

pip install 镜像_pypi私有镜像仓库部署

發布時間:2024/9/18 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pip install 镜像_pypi私有镜像仓库部署 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、pypi私有鏡像倉庫

pypi私有鏡像倉庫可由pypi-web鏡像提供服務,該鏡像一般運行兩個容器:

- pypi-web: 該容器運行web服務nginx負責為python包管理程序pip提供服務,一般長期運行;

- pypi-sync:該容器運行bandersnatch同步程序,負責從http://pypi.org同步數據,周期性運行。

二、服務管理

1.docker-compose.yml文件如下:

version: "3"services:pypi-web:build:context: ./dockerfile: Dockerfileimage: pypi-web:20190723environment:DATA: /dataports:- 8080:80volumes:- /data/pypi:/datapypi-sync:depends_on:- pypi-webimage: pypi-web:20190723environment:DATA: /datavolumes:- /data/pypi:/datacommand: /usr/local/bin/entrypoint.sh sync

2.構建pypi-web鏡像,進入docker-compose.yml文件所在目錄執行:

# docker-compose build

3.啟動服務:

# docker-compose up -d

4.查看服務運行狀態:

# docker-compose top

5.停止服務:

# docker-compose down

6.一般bandersnatch程序運行結束后pypi-sync容器就會停止,如果需要再次同步可以單獨啟動pypi-sync容器:

# docker-compose up -d pypi-sync

7.查看同步日志:

# docker-compose logs -f --tail 100 pypi-sync

三、配置pip使用私有鏡像

1.創建pip配置文件(此處url為ip地址,如果有域名解析建設使用域名)

# cat ~/.pip/pip.conf[global]index-url = http://192.168.9.120:8080/simple/[install]trusted-host = 192.168.9.120

2.使用私有倉庫安裝python包

# pip install XXXX

四、Dockerfile文件如下:

FROM scratchADD centos-7-x86_64-docker.tar.xz /COPY set_mirror.sh /usr/local/binCOPY entrypoint.sh /usr/local/binRUN set -x && find /etc/yum.repos.d -name "*.repo" -exec unlink {} ; && set_mirror.sh && yum clean all && yum install -y gcc make file net-tools wget libffi-devel openssl-devel zlib-devel pcre-devel readline-devel 2>/dev/null && wget -O /tmp/nginx-1.16.0.tar.gz http://nginx.org/download/nginx-1.16.0.tar.gz 2>/dev/null && tar zxf /tmp/nginx-1.16.0.tar.gz -C /tmp && cd /tmp/nginx-1.16.0 && ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre && make && make install && wget -O /tmp/Python-3.6.6.tgz https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz 2>/dev/null && tar zxf /tmp/Python-3.6.6.tgz -C /tmp && cd /tmp/Python-3.6.6 && ./configure --prefix=/usr/local/python3 && make && make install && echo "PATH=/usr/local/nginx/sbin:/usr/local/python3/bin:$PATH" >>/etc/profile && source /etc/profile && pip3 install --upgrade pip && pip3 install pyparsing==2.4.0 bandersnatch==3.4.0 && wget -O /tmp/tini_0.18.0-amd64.rpm https://github.com/krallin/tini/releases/download/v0.18.0/tini_0.18.0-amd64.rpm 2>/dev/null && rpm -ivh /tmp/tini_0.18.0-amd64.rpm && rpm -e gcc && yum clean all && rm -fr /tmp/nginx* /tmp/Python* /tmp/tini*ENTRYPOINT ["/usr/bin/tini", "--"]CMD ["/usr/local/bin/entrypoint.sh"]

五、entrypoint腳本文件如下:

#!/bin/bash#source /etc/profile# Define the data storage directory, default is "/data".DATA=${DATA:=/data}function run_web() {cat > /usr/local/nginx/conf/nginx.conf <<EOFuser nobody;worker_processes 8;worker_rlimit_nofile 65535;events {use epoll;worker_connections 65535;}http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 10;server_tokens off;server {listen 80 default_server;root $DATA/web;autoindex on;autoindex_exact_size off;autoindex_localtime on;charset utf-8;}}EOFif [ ! -d "$DATA/web" ]; thenmkdir -p "$DATA/web"fiexec nginx -g "daemon off;" }function run_sync() {cat > /etc/bandersnatch.conf <<EOF[mirror]directory = $DATAjson = truemaster = https://pypi.orgtimeout = 15workers = 10hash-index = falsestop-on-error = falseverifiers = 3EOFexec bandersnatch mirror}case $1 in"sync")run_sync;;*)run_web;;esac 與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的pip install 镜像_pypi私有镜像仓库部署的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。