github.com/anchore/syft@v1.38.2/syft/pkg/cataloger/python/test-fixtures/image-multi-site-package/Dockerfile (about)

     1  # digest is for linux/amd64
     2  FROM ubuntu:20.04@sha256:cc9cc8169c9517ae035cf293b15f06922cb8c6c864d625a72b7b18667f264b70 AS base
     3  
     4  # install Python 3.8 and Python 3.9
     5  RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y python3.8 python3.9 python3-pip python3-venv python3.9-venv python3.8-venv
     6  
     7  # install pip and virtualenv for both Python versions
     8  RUN python3.8 -m pip install --upgrade pip virtualenv==20.31.2 distlib==0.3.9 filelock==3.16.1 platformdirs==4.3.6
     9  RUN python3.9 -m pip install --upgrade pip virtualenv==20.31.2 distlib==0.3.9 filelock==3.18.0 platformdirs==4.3.8
    10  
    11  # install global packages for Python 3.8 & 3.9
    12  RUN python3.9 -m pip install click==8.0.3 beautifulsoup4==4.9.3 soupsieve==2.2.1 requests==2.25.1
    13  RUN python3.9 -m pip install six==1.16.0 wcwidth==0.2.13 blessed==1.20.0 python-editor==1.0.4  # total dependencies for inquirer in project1 (which is linked)
    14  RUN python3.9 -m pip install requests==2.25.0 certifi==2020.12.5 chardet==3.0.4 idna==2.10 urllib3==1.26.18 # total dependencies for requests
    15  
    16  RUN python3.8 -m pip install readchar==4.2.1
    17  RUN python3.8 -m pip install click==8.0.2 beautifulsoup4==4.9.2 soupsieve==2.2.0 requests==2.25.0
    18  RUN python3.8 -m pip install runs==1.2.2 xmod==1.8.1 # partial dependencies for inquirer in project2 (which is a red herring)
    19  RUN python3.8 -m pip install requests==2.25.0 certifi==2020.12.5 chardet==3.0.4 idna==2.10 urllib3==1.26.18 # total dependencies for requests
    20  
    21  # create directories for the two projects
    22  RUN mkdir -p /app/project1 /app/project2
    23  
    24  # set up the first project with a virtual environment using Python 3.9
    25  WORKDIR /app/project1
    26  RUN python3.9 -m venv --system-site-packages venv
    27  RUN /app/project1/venv/bin/pip install pyyaml==5.4.1 beautifulsoup4==4.10.0 soupsieve==2.3.0 requests # note: use requests from global site packages, but use the rest from the virtual environment
    28  RUN /app/project1/venv/bin/pip install inquirer==3.0.0 # note: should use dependencies from global site packages
    29  
    30  # set up the second project with a virtual environment using Python 3.8
    31  WORKDIR /app/project2
    32  RUN python3.8 -m venv venv
    33  RUN /app/project2/venv/bin/pip install click==8.0.3 pyyaml==6.0
    34  RUN /app/project2/venv/bin/pip install inquirer==3.2.4 runs==1.2.2 xmod==1.8.1 six==1.16.0 wcwidth==0.2.13 blessed==1.20.0 editor==1.6.6 readchar==4.1.0
    35  
    36  WORKDIR /app
    37  
    38  # let's not waste disk space... we only need the above state we've setup, not all of the os-level packages
    39  RUN rm -rf /app/project1/venv/share
    40  RUN rm -rf /app/project2/venv/share
    41  RUN find /app/project1/venv/lib/python3.9/site-packages/* -type d ! -name '*.dist-info' -exec rm -rf {} +
    42  RUN find /app/project2/venv/lib/python3.8/site-packages/* -type d ! -name '*.dist-info' -exec rm -rf {} +
    43  RUN find /usr/local/lib/python3.8/dist-packages/* -type d ! -name '*.dist-info' -exec rm -rf {} +
    44  RUN find /usr/local/lib/python3.9/dist-packages/* -type d ! -name '*.dist-info' -exec rm -rf {} +
    45  
    46  FROM scratch
    47  
    48  COPY --from=base /app/ /app/
    49  COPY --from=base /usr/local/lib/python3.8/ /usr/local/lib/python3.8/
    50  COPY --from=base /usr/local/lib/python3.9/ /usr/local/lib/python3.9/