原创 pip私有源部署

发布时间:2021-06-24 06:47:02 浏览 134 来源:猿笔记 作者:Leo_X

    #贡献主题:##1需求分析,-私有开发源,开发团队需要方便的python私有包发布机制-私有镜像源自建官方源镜像提升访问速度规避偶然网络问题方便离线环境的私有化部署4部署容器-31


    #主题列表:juejin,github,smartblue,cyanosis,channing-cyan,fancy,hydrogen,condensed-night-purple,greenwillow,v-green,vue-pro,healer-readable,mk-cute,jzman,geek-black,awesome-green,qklhk-chocolate

    #投稿主题:

    theme:juejin

    highlight:

    ##1需求分析

    -私有开发来源:开发团队需要方便的python私有包发布机制

    -私有镜像源:自建官方源镜像,提高访问速度,避免意外网络问题,便于离线环境下的私有化部署

    ##2使用Docker部署PypiServer服务器

    ###2.1下载PypiServer镜像

    bashdockerpullpypiserver/pypiserver

    ###2.2生成Auth信息

    bash#安装依赖apt-getinstall-yapache2-utilssudopip3installpasslib#生成htpass文件mkdir-p/opt/pypiserver/auth/opt/pypiserver/packages#表示所有用户都可以读写但不能执行文件/文件夹chmod-R666/opt/pypiserver/packages#会prompt密码输入,重复两遍一样的cd/opt/pypiserver/auth&&htpasswd-sc.htaccess${username}

    ###2.3容器部署

    bashdockerrun-d\\-p${port}:8080\\--restart=always\\--name=pypiserver\\-v/opt/pypiserver/packages/:/data/packages\\-v/opt/pypiserver/auth:/data/auth/\\pypiserver/pypiserver-P/data/auth/.htaccess-aupdate/data/packages

    ###2.4Nginx反向代理

    -使用Docker部署Nginx服务,同时提供HTTPS支持

    nginxecho'server{listen80;server_name${sever_name];rewrite^(.*)$https://${server_name}$1permanent;}server{listen443ssl;server_name${server_name};#ssl证书文件位置(常见证书文件格式为:crt/pem)ssl_certificate/etc/nginx/ssl/ps-cert.pem;#ssl证书key位置ssl_certificate_key/etc/nginx/ssl/ps-cert.key;ssl_session_timeout10m;ssl_protocolsTLSv1TLSv1.1TLSv1.2;ssl_ciphersECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_prefer_server_cipherson;location/{proxy_set_headerHost$host;proxy_set_headerX-Forwarded-Proto$scheme;proxy_set_headerX-Forwarded-For$host;proxy_set_headerX-Real-IP$remote_addr;#此处可以使用frp做穿透,将内网的服务映射到公网上proxy_passhttp://${public_ip}:${port};}}'>>/opt/pypi/pypi.conf-部署Nginx容器bashdockerrun-d\\--restartalways\\-v/opt/pypi/pypi.conf:/etc/nginx/conf.d/pypi.conf\\-v/opt/pypi/ssl/ps-cert.pem:/etc/nginx/ssl/ps-cert.pem\\-v/opt/pypi/ssl/ps-cert.key:/etc/nginx/ssl/ps-cert.key\\-p${port}:80\\--name=pypi_nginxnginx##3安装bandersnatch本地源同步工具###3.1本机配置配置文件bashmkdir-p/opt/bandersnatch/log&&touch/opt/bandersnatch/bandersnatch.conf/opt/bandersnatch/bandersnatch-log.confecho'[mirror]directory=/opt/bandersnatchjson=falserelease-files=truecleanup=falsemaster=https://pypi.orgtimeout=10global-timeout=1800workers=3hash-index=falsestop-on-error=falsestorage-backend=filesystem;log-config=/opt/bandersnatch/bandersnatch-log.conf;root_uri=https://example.comverifiers=3;keep_index_versions=0;vim:setft=cfg:;diff-file=/srv/pypi/mirrored-files;diff-append-epoch=true[plugins]enabled=all[blacklist];https://bandersnatch.readthedocs.io/en/latest/filtering_configuration.html;https://pypi.org/stats/[whitelist]packages=cntktensorflow-gputensorflowtensorflow-cputorch'>/opt/bandersnatch/bandersnatch.conf\\&&echo'[loggers]keys=root,file[handlers]keys=root,file[formatters]keys=common[logger_root]level=NOTSEThandlers=root[logger_file]level=INFOhandlers=filepropagate=1qualname=bandersnatch[formatter_common]format=%(asctime)s%(name)-12s:%(levelname)s%(message)s[handler_root]class=StreamHandlerlevel=DEBUGformatter=commonargs=(sys.stdout,)[handler_file]class=handlers.RotatingFileHandlerlevel=INFOformatter=commonargs=('/opt/bandersnatch/log/bandersnatch.log','D',1,'UTF-8')#willmanageonefileaday'>/opt/bandersnatch/bandersnatch-log.conf

    部署容器

    bashdockerrun-d\\--restart=always\\--name=bandersnatch\\-v/opt/bandersnatch/bandersnatch.conf:/etc/bandersnatch.conf\\-v/opt/bandersnatch:/opt/bandersnatch\\pypa/bandersnatchbandersnatchmirror

    ###3.2nginx反向代理配置

    使用Docker部署Nginx服务,nginx配置文件如下

    nginxserver{listen80;server_name${server_name};rewrite^(.*)$https://${server_name}$1permanent;}server{listen443ssl;server_name${server_name};#ssl证书文件位置(常见证书文件格式为:crt/pem)ssl_certificate/etc/nginx/ssl/bs-cert.pem;#ssl证书key位置ssl_certificate_key/etc/nginx/ssl/bs-cert.key;ssl_session_timeout10m;ssl_protocolsTLSv1TLSv1.1TLSv1.2;ssl_ciphersECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_prefer_server_cipherson;location/{proxy_set_headerHost$host;proxy_set_headerX-Forwarded-Proto$scheme;proxy_set_headerX-Forwarded-For$host;proxy_set_headerX-Real-IP$remote_addr;#此处可以使用frp做穿透,将内网的服务映射到公网上proxy_passhttp://${public_ip}:${port};}}

    ##5参考

    -PypiServer

    -

    -

    -[PypiServerDockerHub](

    -bandersnatch

    -

    -

    -[Mirrorconfiguration](

作者信息

Leo_X [等级:3]
发布了 13 篇专栏 · 获得点赞 6 · 获得阅读 897

相关推荐 更多