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

A brief talk about JavaScript variable promotion

Table of contents Preface 1. What variables are p...

Linux Dig command usage

Dig Introduction: Dig is a tool that queries DNS ...

A brief discussion on event-driven development in JS and Nodejs

Table of contents Event-driven and publish-subscr...

A method of hiding processes under Linux and the pitfalls encountered

Preface 1. The tools used in this article can be ...

MySQL 5.5 installation and configuration graphic tutorial

Organize the MySQL 5.5 installation and configura...

Typescript+react to achieve simple drag and drop effects on mobile and PC

This article shares the specific code of typescri...

MySql implements page query function

First of all, we need to make it clear why we use...

Detailed tutorial on installing Hbase 2.3.5 on Vmware + Ubuntu18.04

Preface The previous article installed Hadoop, an...

JavaScript+HTML to implement student information management system

Table of contents 1. Introduction 2. Rendering 3....

How to use resident nodes for layer management in CocosCreator

CocosCreator version: 2.3.4 Most games have layer...

Can asynchrony in JavaScript save await?

I knew before that to synchronously obtain the re...

Detailed explanation of Linux lsof command usage

lsof (list open files) is a tool to view files op...

CSS3 realizes the mask barrage function

Recently I saw a barrage effect on B station call...

About the IE label LI text wrapping problem

I struggled with this for a long time, and after s...