Dockerfileイメージ構築
- Dockerfile
FROM python:3.12.2-slim
WORKDIR /app
COPY startup.sh ./
COPY package-sources /etc/apt/sources.list
COPY debian-repo /etc/apt/sources.list.d/
RUN apt-get update &&\
apt-get install -y vim net-tools procps nginx &&\
pip install devpi devpi-web supervisor &&\
chmod +x /app/startup.sh
ENTRYPOINT ["/app/startup.sh"]
- startup.sh
#!/bin/bash
devpi-init --serverdir=/app/pypi-repo
/usr/local/bin/devpi-server --host=0.0.0.0 --port=3141 --serverdir /app/pypi-repo
- debian-repo
Types: deb
URIs: http://mirrors.aliyun.com/debian
Suites: bookworm bookworm-updates
Components: main non-free contrib
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb
URIs: http://mirrors.aliyun.com/debian-security
Suites: bookworm-security
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
- package-sources
deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
- docker build -t pypi-server:1.8 .
docker-compose 設定ファイル
- ppi-server.yml (マウントディレクトリは適宜変更してください)
version: "3"
services:
pypi-server:
container_name: "pypi-server"
privileged: true
image: "pypi-server:1.8"
restart: always
network_mode: host
volumes:
- /data/pypi-server/packages:/app/pypi-repo
- docker-compose -f ppi-server.yml up -d
devpi-server 環境の初期化
- devpi-clientのインストール (localhostはご自身のIPに置き換えてください。初期化は一度だけ必要です。ネットワークに接続できていれば pip3 install -i "http://localhost:3141/root/pypi/+simple/" jwt --trusted-host localhost が使用できます)
pip3 install devpi-client -i https://mirrors.aliyun.com/pypi/simple/
dev use http://localhost:3141/root/py
# 初期パスワードは空でEnterキーを押す
devpi login root
# アリババクラウドのミラーソースに変更
devpi index root/pypi "mirror_web_url_fmt=https://mirrors.aliyun.com/pypi/simple/{name}/" \
"mirror_url=https://mirrors.aliyun.com/pypi/simple/"
# これでパッケージをインストールできるようになります
pip3 install -i "http://localhost:3141/root/pypi/+simple/" jwt --trusted-host localhost
-
動作確認画面
-
Web管理画面
注意点
- devpi-serverはインデックスを取得するためにしばらく時間がかかります
- Pythonパッケージのインストール中のログを確認してください