Dockerfile 2.48 KB
Newer Older
Aoyang Fang's avatar
Aoyang Fang committed
1
# Use the official Ubuntu base image
2
3
4
FROM swr.cn-central-221.ovaijisuan.com/mindformers/mindformers1.2_mindspore2.3:20240722

USER root
Aoyang Fang's avatar
Aoyang Fang committed
5
6
7
8
9
10
11
12

# Set environment variables to non-interactive to avoid prompts during installation
ENV DEBIAN_FRONTEND=noninteractive

# Update the package list and install necessary packages
RUN apt-get update && \
    apt-get install -y \
        software-properties-common && \
13
    add-apt-repository -y ppa:deadsnakes/ppa && \
Aoyang Fang's avatar
Aoyang Fang committed
14
15
16
17
18
    apt-get update && \
    apt-get install -y \
        python3.10 \
        python3.10-venv \
        python3.10-distutils \
19
20
        python3.10-dev \
        python3-pip \
Aoyang Fang's avatar
Aoyang Fang committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        wget \
        git \
        libgl1 \
        libglib2.0-0 \
        && rm -rf /var/lib/apt/lists/*

# Set Python 3.10 as the default python3
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1

# Create a virtual environment for MinerU
RUN python3 -m venv /opt/mineru_venv

# Activate the virtual environment and install necessary Python packages
RUN /bin/bash -c "source /opt/mineru_venv/bin/activate && \
35
    pip3 install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple && \
36
    wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docker/ascend_npu/requirements.txt -O requirements.txt && \
37
    pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple && \
38
    wget https://gitee.com/ascend/pytorch/releases/download/v6.0.rc2-pytorch2.3.1/torch_npu-2.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl && \
39
    pip3 install torch_npu-2.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl"
40
41

# Copy the configuration file template and install magic-pdf latest
42
RUN /bin/bash -c "wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/magic-pdf.template.json && \
43
44
    cp magic-pdf.template.json /root/magic-pdf.json && \
    source /opt/mineru_venv/bin/activate && \
45
    pip3 install -U magic-pdf -i https://mirrors.aliyun.com/pypi/simple"
46
47

# Download models and update the configuration file
48
49
RUN /bin/bash -c "source /opt/mineru_venv/bin/activate && \
    pip3 install modelscope -i https://mirrors.aliyun.com/pypi/simple && \
50
    wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/scripts/download_models.py -O download_models.py && \
51
    python3 download_models.py && \
52
    sed -i 's|cpu|npu|g' /root/magic-pdf.json"
Aoyang Fang's avatar
Aoyang Fang committed
53
54

# Set the entry point to activate the virtual environment and run the command line tool
Xiaomeng Zhao's avatar
Xiaomeng Zhao committed
55
ENTRYPOINT ["/bin/bash", "-c", "source /opt/mineru_venv/bin/activate && exec \"$@\"", "--"]