File size: 2,175 Bytes
863d8a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
FROM python:3.9

# 创建用户并切换到该用户
RUN useradd -m -u 1000 user

# 设置环境变量
ENV PATH="/home/user/.local/bin:$PATH"

# /home/user/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN echo $PATH

# 设置环境变量,以避免在安装过程中出现交互提示
ENV DEBIAN_FRONTEND=noninteractive

# 设置工作目录
WORKDIR /app
USER root

# # 安装 sudo
RUN apt-get update && apt-get install -y sudo supervisor

# 克隆并安装 scipdf_parser
RUN git clone -q https://github.com/titipata/scipdf_parser.git
RUN pip install -q git+https://github.com/titipata/scipdf_parser

# 进入 scipdf_parser 目录并安装 spaCy 模型
WORKDIR /app/scipdf_parser
RUN python -m spacy download en_core_web_sm

# 返回工作目录
WORKDIR /app

# 复制requirements.txt文件并安装Python依赖
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install -q python-multipart
RUN pip install -q --upgrade pip
RUN pip install -q --upgrade -r requirements.txt

# 下载并解压 OpenJDK 11
RUN wget -q  https://download.oracle.com/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz \
    && tar -zxvf openjdk-11.0.2_linux-x64_bin.tar.gz > /dev/null \
    && mv jdk-11.0.2 /opt/ \
    && rm openjdk-11.0.2_linux-x64_bin.tar.gz

# 设置环境变量
ENV JAVA_HOME=/opt/jdk-11.0.2
ENV PATH=$JAVA_HOME/bin:$PATH

# 验证 Java 安装
RUN java -version

# RUN sudo apt-get install -y maven
RUN wget -q  https://github.com/kermitt2/grobid/archive/0.7.3.zip
RUN unzip 0.7.3.zip > /dev/null

# 安装依赖
RUN git clone -q https://github.com/kermitt2/grobid.git


WORKDIR /app/grobid
RUN chmod +x gradlew

RUN ./gradlew clean install --console=plain

WORKDIR /app
# 暴露端口
EXPOSE 8070
EXPOSE 7860
COPY --chown=user ./start.sh start.sh

RUN chmod +x start.sh
RUN chmod -R 777 grobid

# 复制应用程序代码
COPY --chown=user . /app
CMD ["./start.sh"]

# CMD ["supervisord", "-c", "supervisord.conf"]

# # 设置默认命令
# CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]

# "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"
# uvicorn app:app --host "0.0.0.0" --port 7860