1
1
ARG INSTALL_OCI_REGISTRY_VER="2.8.2"
2
2
ARG DOTNET_CONTAINER_VARIANT="6.0-jammy"
3
-
3
+ ARG PYPISERVER_PORT=8080
4
+ ARG PYPI_SERVER_VERSION="2.1.1"
5
+ ARG OCI_REGISTRY_PORT=5000
4
6
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${DOTNET_CONTAINER_VARIANT} AS downloader
5
7
ARG INSTALL_OCI_REGISTRY_VER="2.8.2"
6
8
ENV INSTALL_OCI_REGISTRY_VER=${INSTALL_OCI_REGISTRY_VER}
@@ -20,19 +22,78 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
20
22
RUN mkdir -p /htpasswd/libs
21
23
RUN ldd /usr/bin/htpasswd | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /htpasswd/libs
22
24
23
- # FROM mcr.microsoft.com/cbl-mariner/distroless/minimal:2.0
24
- FROM mcr.microsoft.com/cbl-mariner/distroless/base:2.0
25
+ # Setup PypiServer
26
+ FROM mcr.microsoft.com/devcontainers/python:1-3.9 as pypi_builder
27
+ ARG PYPI_SERVER_VERSION="2.1.1"
28
+ ENV PYPI_SERVER_VERSION=${PYPI_SERVER_VERSION}
29
+
30
+ RUN apt-get update && apt-get install -y --no-install-recommends \
31
+ ca-certificates \
32
+ gnupg \
33
+ wget \
34
+ git \
35
+ curl \
36
+ tar \
37
+ libffi-dev \
38
+ tree
39
+
40
+ RUN curl --silent --fail --create-dirs --output /code/pypiserver.tar.gz -L https://github.com/pypiserver/pypiserver/archive/refs/tags/v${PYPI_SERVER_VERSION}.tar.gz \
41
+ && tar -xvzf /code/pypiserver.tar.gz -C /code/
42
+
43
+ WORKDIR /code/pypiserver-${PYPI_SERVER_VERSION}
44
+
45
+ RUN python -m pip install \
46
+ --no-warn-script-location \
47
+ --prefix=/pypi-server \
48
+ --requirement docker/docker-requirements.txt
25
49
50
+ RUN python -m pip install \
51
+ --no-warn-script-location \
52
+ --prefix=/pypi-server \
53
+ .
54
+
55
+ RUN mkdir -p /code/pypiserver-${PYPI_SERVER_VERSION}/docker/data/packages
56
+
57
+ COPY src/gunicorn.conf.py /code/pypiserver-${PYPI_SERVER_VERSION}/docker/data/gunicorn.conf.py
58
+
59
+ FROM mcr.microsoft.com/cbl-mariner/base/python:3.9 as final
60
+ ARG OCI_REGISTRY_PORT=5000
26
61
ARG INSTALL_OCI_REGISTRY_VER="2.8.2"
62
+ ARG PYPI_SERVER_VERSION="2.1.1"
63
+ ARG PYPISERVER_PORT=8080
64
+
65
+ ENV OCI_REGISTRY_PORT=${OCI_REGISTRY_PORT}
66
+ ENV PYPI_SERVER_VERSION=${PYPI_SERVER_VERSION}
67
+ ENV PYPISERVER_PORT=${PYPISERVER_PORT}
68
+
69
+ # Flush logs immediately to stdout
70
+ ENV PYTHONUNBUFFERED=t
71
+
72
+ ENV PYTHONPATH=/pypi-server/lib/python3.9/site-packages/
73
+
74
+ RUN ln -s /usr/bin/python3 /usr/bin/python \
75
+ && ln -s /usr/bin/python3 /usr/local/bin/python
76
+
77
+ # Copy the registry binaries and the configuration file
27
78
COPY src/registry-config.yml /etc/docker/registry/config.yml
28
79
COPY --from=downloader /registry /bin/registry
29
80
30
81
# Pull in the shared libraries from the downloader so we can run htpasswd
31
82
COPY --from=downloader /usr/bin/htpasswd /usr/bin/htpasswd
32
83
COPY --from=downloader /htpasswd/libs/* /usr/lib/
33
84
85
+ # Copy the built pypi-server files
86
+ COPY --from=pypi_builder /pypi-server /pypi-server
87
+ COPY --from=pypi_builder /code/pypiserver-${PYPI_SERVER_VERSION}/docker/data /data
88
+ COPY --chmod=0755 src/entrypoint.sh /entrypoint.sh
89
+
90
+
91
+ VOLUME "/var/lib/registry"
92
+ VOLUME "/data/packages"
93
+ EXPOSE ${OCI_REGISTRY_PORT} ${PYPISERVER_PORT}
94
+
95
+ USER root
96
+
97
+ ENTRYPOINT ["/entrypoint.sh" ]
98
+
34
99
35
- VOLUME ["/var/lib/registry" ]
36
- EXPOSE 5000
37
- ENTRYPOINT ["registry" ]
38
- CMD ["serve" , "/etc/docker/registry/config.yml" ]
0 commit comments