File size: 3,080 Bytes
5142c8f
 
 
 
 
 
 
 
 
0ff93ec
ba92a3e
3aba120
0ff93ec
ba92a3e
5142c8f
c547531
3aba120
7574c0c
0ff93ec
5142c8f
 
 
 
 
 
 
 
7574c0c
 
 
5142c8f
 
 
46b5cd6
 
 
 
 
 
5142c8f
 
 
 
0ff93ec
 
 
 
 
 
 
 
 
 
 
 
 
5142c8f
 
0ff93ec
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
# Starting from the Grobid image
FROM lfoppiano/grobid:0.7.3

# Setting the user to root for installation purposes
USER root

# Create necessary directories for Grobid
RUN mkdir -m 777 -p /opt/grobid/grobid-home/tmp

# Give permissions to the default supervisord log directory and Gradio logs
RUN mkdir -p /var/log/supervisor && chmod -R 777 /var/log/supervisor
RUN mkdir -p /var/run/supervisor && chmod 777 /var/run/supervisor
RUN mkdir -p /var/log/gradio && chmod 777 /var/log/gradio

# Install supervisord and python (for gradio)
RUN apt-get update && apt-get install -y supervisor python3 python3-pip git && rm -rf /var/lib/apt/lists/*
RUN pip3 install gradio
RUN pip3 install git+https://github.com/titipata/scipdf_parser
RUN pip3 install git+https://github.com/coderanger/supervisor-stdout

# Copy your gradio app to the image
COPY . /app/
COPY ./data /app/data

# Install gradio
RUN pip3 install -r /app/requirements.txt

# Download spacy en_core_web_sm
RUN python3 -m spacy download en_core_web_sm

# Supervisord configuration
RUN echo "[supervisord]" > /etc/supervisor/conf.d/supervisord.conf && \
    echo "nodaemon=true" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "[rpcinterface:supervisor]" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "[unix_http_server]" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "file=/tmp/supervisor.sock" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "[program:grobid]" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "command=/opt/grobid/grobid-service/bin/grobid-service" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "[program:gradio]" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "command=python3 /app/main.py" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "stdout_logfile=/dev/fd/1" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "stdout_logfile_maxbytes=0" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "redirect_stderr=true" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "stdout_events_enabled=true" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "stderr_events_enabled=true" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "[eventlistener:stdout]" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "command = supervisor_stdout" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "buffer_size = 100" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "events = PROCESS_LOG" >> /etc/supervisor/conf.d/supervisord.conf && \
    echo "result_handler = supervisor_stdout:event_handler" >> /etc/supervisor/conf.d/supervisord.conf
    

# Start processes with supervisord
CMD ["/usr/bin/supervisord"]