How to use Docker to build a pypi private repository

How to use Docker to build a pypi private repository

1. Construction

1. Prepare htpasswd.txt file

The file contains the username and password for verification when uploading the package to the warehouse.

pip install htpasswd
htpasswd -sc htpasswd.txt <username>

2. Start the container

docker run --name pypiserver --restart=always -v /data/pypi/packages:/data/packages -v /root/htpasswd.txt:/data/htpasswd.txt -p 8080:8080 -d pypiserver/pypiserver -P htpasswd.txt packages
#You need to create the data directory and htpasswd.txt file on the host in advance

3. Set up nginx reverse proxy

cat /usr/local/nginx/conf/exten/pypi.conf
upstream pypi {
          server 127.0.0.1:8080;
      }
 
server {
 
    listen 80;
    server_name pypi.local.me;
    location / {
          proxy_pass_header Server;
          proxy_set_header Host $http_host;
          proxy_redirect off;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Scheme $scheme;
          proxy_pass http://pypi;
          }
}

2. Use

1. Create a test project

# Create a project directory mkdir -p linode_example/linode_example
# Create setup.py
cat linode_example/setup.py
from setuptools import setup
setup(
   name='linode_example',
   packages=['linode_example'], #Directory after uploading to the warehouse, such as http://pypi.local.me/linode_example
   description = 'Hello world enterprise edition',
   version='0.1', # version number url='http://github.com/example/linode_example',
   author='Linode',
   keywords=['pip','linode','example']
   )
# The content of this file is for explanatory purposes only. You can set it according to your own package. # Create the __init__.py main program cat linode_example/linode_example/__init__.py
def hello_word():
   print("hello world")
 
#Package and upload python3.7 setup.py sdist #Package. After execution, there will be a tarball in the dist directory twine upload --repository-url http://pypi.local.me dist/* #Username and password are required when uploading: admin/admin123

2. Use the package uploaded to the warehouse

pip install -i http://pypi.local.me --trusted-host pypi.local.me linode_example

Packing Notes:

1. The directory structure of all projects that need to be packaged in the git repository must be consistent to facilitate automated integration of Jenkinsfile;

2. The setup.py files of all projects that need to be packaged must be located in the project root directory;

3. Python uses a unified version, and the version of each project needs to be fixed to facilitate iteration.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • The process of building a docker registry private warehouse
  • Detailed tutorial on installing harbor private warehouse using docker compose
  • Docker-compose quickly builds steps for Docker private warehouse
  • Steps for Docker to build a private warehouse Harbor
  • The process of docker establishing a private warehouse

<<:  Summary of 10 amazing tricks of Element-UI

>>:  Q&A: Differences between XML and HTML

Recommend

Web page comments cause text overflow in IE

The experimental code is as follows: </head>...

Summary of two methods to implement vue printing function

Method 1: Install the plugin via npm 1. Install n...

Example of how to configure multiple virtual hosts in nginx

It is very convenient to configure virtual host v...

Detailed explanation of explain type in MySQL

Introduction: In many cases, many people think th...

Detailed explanation of mysql permissions and indexes

mysql permissions and indexes The highest user of...

Several ways to add timestamps in MySQL tables

Scenario: The data in a table needs to be synchro...

Use the sed command to modify the kv configuration file in Linux

sed is a character stream editor under Unix, that...

What is this in JavaScript point by point series

Understand this Perhaps you have seen this in oth...

Analysis of 2 Token Reasons and Sample Code in Web Project Development

Table of contents question: There are 2 tokens in...

Detailed explanation of the use of Vue image drag and drop zoom component

The specific usage of the Vue image drag and drop...

js dynamically implements table addition and deletion operations

This article example shares the specific code for...