forked from Code4PuertoRico/contratospr-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
55 lines (42 loc) · 1.2 KB
/
Dockerfile
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
FROM python:3.7 as builder
ENV POPPLER_VERION 0.74.0
# Install pdftotext
RUN apt-get update && \
apt-get install -y cmake && \
cd /tmp && \
curl -L "https://poppler.freedesktop.org/poppler-${POPPLER_VERION}.tar.xz" | tar xJ && \
cd "poppler-${POPPLER_VERION}" && \
mkdir build && \
cd build && \
cmake .. \
-DCMAKE_INSTALL_PREFIX=/tmp/poppler \
-DCMAKE_BUILD_TYPE=release \
-DBUILD_SHARED_LIBS=OFF \
-DENABLE_LIBOPENJPEG=none && \
make && \
make install && \
rm -rf /var/lib/apt/lists/*
FROM python:3.7
ARG PIPENV_ARGS
ENV LANG en_US.utf8
ENV PYTHONUNBUFFERED 1
# Install tesseract
RUN apt-get update && apt-get install -y \
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-spa && \
rm -rf /var/lib/apt/lists/*
# Add app user
RUN adduser --disabled-login app
RUN pip install pipenv==2018.11.26
WORKDIR /app/
COPY --from=builder /tmp/poppler/bin/pdftotext /usr/local/bin/
COPY --from=builder /tmp/poppler/bin/pdftoppm /usr/local/bin/
COPY --from=builder /tmp/poppler/bin/pdfinfo /usr/local/bin/
COPY Pipfile Pipfile.lock /app/
# Install application requirements
RUN pipenv install --deploy --system $PIPENV_ARGS && \
rm -rf /root/.cache
# Bundle app source
COPY . /app/
USER app