Commit ce6a2b6708b09ba851a78051f882a3010333ad3d
1 parent
5eec72f7
Exists in
master
and in
1 other branch
Documentação do container Docker no manual de instalação INSTALL.txt
Showing
2 changed files
with
44 additions
and
10 deletions
Show diff stats
Dockerfile
@@ -6,6 +6,9 @@ COPY usr/local/bin/ocr /usr/local/bin/ocr | @@ -6,6 +6,9 @@ COPY usr/local/bin/ocr /usr/local/bin/ocr | ||
6 | COPY etc/init.d/ocr-ubuntu /etc/init.d/ocr | 6 | COPY etc/init.d/ocr-ubuntu /etc/init.d/ocr |
7 | COPY entrypoint.sh /entrypoint.sh | 7 | COPY entrypoint.sh /entrypoint.sh |
8 | 8 | ||
9 | +WORKDIR /tmp | ||
10 | + | ||
11 | +# Instalação dos pacotes pré-requisitos do ocr-server 2 | ||
9 | RUN apt-get -y update && \ | 12 | RUN apt-get -y update && \ |
10 | apt-get -y install build-essential cmake libtool yasm pkg-config subversion git libgcj14 apt-utils \ | 13 | apt-get -y install build-essential cmake libtool yasm pkg-config subversion git libgcj14 apt-utils \ |
11 | curl libtiff-dev libpng-dev libopenjpeg-dev libjpeg8-dev libjpeg-turbo8-dev libjpeg-dev libgif-dev \ | 14 | curl libtiff-dev libpng-dev libopenjpeg-dev libjpeg8-dev libjpeg-turbo8-dev libjpeg-dev libgif-dev \ |
@@ -17,7 +20,8 @@ RUN apt-get -y update && \ | @@ -17,7 +20,8 @@ RUN apt-get -y update && \ | ||
17 | apt-get -y clean all | 20 | apt-get -y clean all |
18 | 21 | ||
19 | RUN wget -O mscorefonts.deb http://ftp.us.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.4+nmu1_all.deb && \ | 22 | RUN wget -O mscorefonts.deb http://ftp.us.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.4+nmu1_all.deb && \ |
20 | - dpkg -i mscorefonts.deb | 23 | + dpkg -i mscorefonts.deb && \ |
24 | + rm mscorefonts.deb | ||
21 | 25 | ||
22 | # Instalação do Perl 5.1 e demais módulos | 26 | # Instalação do Perl 5.1 e demais módulos |
23 | RUN perl -MCPAN -e 'install File::Touch' | 27 | RUN perl -MCPAN -e 'install File::Touch' |
@@ -30,37 +34,48 @@ RUN perl -MCPAN -e 'install IO::Select;' | @@ -30,37 +34,48 @@ RUN perl -MCPAN -e 'install IO::Select;' | ||
30 | # Tesseract-ocr 3.05, com dicionários inglês e português | 34 | # Tesseract-ocr 3.05, com dicionários inglês e português |
31 | # Bibliotecas para o Tesseract: Leptonica | 35 | # Bibliotecas para o Tesseract: Leptonica |
32 | RUN git clone https://github.com/DanBloomberg/leptonica.git && \ | 36 | RUN git clone https://github.com/DanBloomberg/leptonica.git && \ |
33 | - cd leptonica && ./autobuild && ./configure && make all install | 37 | + cd leptonica && ./autobuild && ./configure && make all install && \ |
38 | + rm -rf ../leptonica | ||
34 | 39 | ||
35 | # Bibliotecas para o Tesseract: Libav | 40 | # Bibliotecas para o Tesseract: Libav |
36 | RUN git clone https://github.com/libav/libav.git && \ | 41 | RUN git clone https://github.com/libav/libav.git && \ |
37 | export PKG_CONFIG_PATH=/usr/lib:/usr/local/lib:/usr/local/src/leptonica/ && \ | 42 | export PKG_CONFIG_PATH=/usr/lib:/usr/local/lib:/usr/local/src/leptonica/ && \ |
38 | - cd libav && ./configure --enable-sram && make all install | 43 | + cd libav && ./configure --enable-sram && make all install && \ |
44 | + rm -rf ../libav | ||
39 | 45 | ||
40 | -# Tesseract | 46 | +# Tesseract 3.05.01 |
41 | RUN git clone https://github.com/tesseract-ocr/tesseract.git && \ | 47 | RUN git clone https://github.com/tesseract-ocr/tesseract.git && \ |
42 | - cd tesseract && ./autogen.sh && ./configure && make all install | 48 | + cd tesseract && ./autogen.sh && ./configure && make all install && \ |
49 | + rm -rf ../tesseract | ||
43 | 50 | ||
44 | RUN wget https://github.com/tesseract-ocr/tessdata/blob/master/eng.traineddata?raw=true -O /usr/local/share/tessdata/eng.traineddata && \ | 51 | RUN wget https://github.com/tesseract-ocr/tessdata/blob/master/eng.traineddata?raw=true -O /usr/local/share/tessdata/eng.traineddata && \ |
45 | wget https://github.com/tesseract-ocr/tessdata/blob/master/por.traineddata?raw=true -O /usr/local/share/tessdata/por.traineddata && \ | 52 | wget https://github.com/tesseract-ocr/tessdata/blob/master/por.traineddata?raw=true -O /usr/local/share/tessdata/por.traineddata && \ |
46 | wget https://github.com/tesseract-ocr/tessdata/blob/master/osd.traineddata?raw=true -O /usr/local/share/tessdata/osd.traineddata | 53 | wget https://github.com/tesseract-ocr/tessdata/blob/master/osd.traineddata?raw=true -O /usr/local/share/tessdata/osd.traineddata |
47 | 54 | ||
55 | +# Poppler 0.56 | ||
48 | RUN git clone -b poppler-0.56 https://anongit.freedesktop.org/git/poppler/poppler.git && \ | 56 | RUN git clone -b poppler-0.56 https://anongit.freedesktop.org/git/poppler/poppler.git && \ |
49 | - cd poppler && ./autogen.sh && ./configure --enable-cmyk --enable-libcurl && make all install && cd .. | 57 | + cd poppler && ./autogen.sh && ./configure --enable-cmyk --enable-libcurl && make all install && \ |
58 | + rm -rf ../poppler | ||
50 | 59 | ||
51 | # pdftk, versão 2.02 ou superior | 60 | # pdftk, versão 2.02 ou superior |
52 | RUN wget https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-2.02-src.zip && \ | 61 | RUN wget https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-2.02-src.zip && \ |
53 | unzip pdftk-2.02-src.zip && rm -f pdftk-2.02-src.zip && \ | 62 | unzip pdftk-2.02-src.zip && rm -f pdftk-2.02-src.zip && \ |
54 | - cd pdftk-2.02-dist/pdftk && make -f Makefile.Redhat all install | 63 | + cd pdftk-2.02-dist/pdftk && make -f Makefile.Redhat all install && \ |
64 | + rm -rf ../pdftk-2.02-dist | ||
55 | 65 | ||
56 | # Ghostscript 9.18 ou superior | 66 | # Ghostscript 9.18 ou superior |
57 | RUN wget http://downloads.ghostscript.com/public/old-gs-releases/ghostscript-9.18.tar.gz && \ | 67 | RUN wget http://downloads.ghostscript.com/public/old-gs-releases/ghostscript-9.18.tar.gz && \ |
58 | tar xvozf ghostscript-9.18.tar.gz && rm -f ghostscript-9.18.tar.gz && \ | 68 | tar xvozf ghostscript-9.18.tar.gz && rm -f ghostscript-9.18.tar.gz && \ |
59 | - cd ghostscript-9.18 && ls && ./autogen.sh; ./configure && make all install | 69 | + cd ghostscript-9.18 && ls && ./autogen.sh; ./configure && make all install && \ |
70 | + rm -rf ../ghostscript-9.18 | ||
60 | 71 | ||
72 | +# CPDF Intel OS X v 2.2 | ||
61 | RUN git clone https://github.com/coherentgraphics/cpdf-binaries.git && \ | 73 | RUN git clone https://github.com/coherentgraphics/cpdf-binaries.git && \ |
62 | cp cpdf-binaries/Linux-Intel-64bit/cpdf /usr/bin | 74 | cp cpdf-binaries/Linux-Intel-64bit/cpdf /usr/bin |
63 | 75 | ||
76 | +# Atualização das configurações do ld | ||
77 | +RUN ldconfig | ||
78 | + | ||
64 | RUN useradd -m ocr | 79 | RUN useradd -m ocr |
65 | 80 | ||
66 | RUN chmod +x /usr/local/bin/ocr && \ | 81 | RUN chmod +x /usr/local/bin/ocr && \ |
@@ -72,7 +87,7 @@ RUN mkdir /var/ocr-server/ && \ | @@ -72,7 +87,7 @@ RUN mkdir /var/ocr-server/ && \ | ||
72 | mkdir -p /var/ocr-server/Saida && \ | 87 | mkdir -p /var/ocr-server/Saida && \ |
73 | mkdir -p /var/ocr-server/Originais_Processados && \ | 88 | mkdir -p /var/ocr-server/Originais_Processados && \ |
74 | mkdir -p /var/ocr-server/Erro && \ | 89 | mkdir -p /var/ocr-server/Erro && \ |
75 | - chmod +x entrypoint.sh | 90 | + chmod +x /entrypoint.sh |
76 | 91 | ||
77 | RUN mkdir -p /tmp/ocr_dev/ && \ | 92 | RUN mkdir -p /tmp/ocr_dev/ && \ |
78 | mkdir -p /tmp/ocr_dev/Entrada && \ | 93 | mkdir -p /tmp/ocr_dev/Entrada && \ |
@@ -81,6 +96,8 @@ RUN mkdir -p /tmp/ocr_dev/ && \ | @@ -81,6 +96,8 @@ RUN mkdir -p /tmp/ocr_dev/ && \ | ||
81 | mkdir -p /tmp/ocr_dev/Erro && \ | 96 | mkdir -p /tmp/ocr_dev/Erro && \ |
82 | chmod -R 777 /tmp/ocr_dev | 97 | chmod -R 777 /tmp/ocr_dev |
83 | 98 | ||
99 | +WORKDIR / | ||
100 | + | ||
84 | VOLUME /var/ocr-server/ | 101 | VOLUME /var/ocr-server/ |
85 | 102 | ||
86 | -CMD ["bash", "entrypoint.sh"] | ||
87 | \ No newline at end of file | 103 | \ No newline at end of file |
104 | +CMD ["bash", "/entrypoint.sh"] | ||
88 | \ No newline at end of file | 105 | \ No newline at end of file |
README.md
@@ -239,3 +239,20 @@ Quanto ao CPDF, é possível baixar a versão binária em: https://github.com/co | @@ -239,3 +239,20 @@ Quanto ao CPDF, é possível baixar a versão binária em: https://github.com/co | ||
239 | 239 | ||
240 | # Inicie o serviço com | 240 | # Inicie o serviço com |
241 | service ocr start | 241 | service ocr start |
242 | + | ||
243 | + | ||
244 | +## Container Docker | ||
245 | + | ||
246 | + O ocr-server também está disponível como um container Docker, permitindo o rápido provisionamento da solução em ambiente de produção. Todos os procedimento para construção da imagem do container podem ser encontrados no arquivo Dockerfile. | ||
247 | + Para execução do serviço, basta que o docker instalado no servidor e executar o seguinte comando: | ||
248 | + | ||
249 | + docker run --name <NOME_CONTAINER> -d -v <DIRETORIO_BASE>:/var/ocr-server guilhermeadc/ocr-server | ||
250 | + | ||
251 | + onde: | ||
252 | + --name : Nome atribuído à instância do container. Ex: ocr-server | ||
253 | + -d : Indicação executar o container em background | ||
254 | + -v : Diretório de compartilhamento entre o servidor host e o container. | ||
255 | + O parâmetro <DIRETORIO_BASE> deve ser substituído pelo diretório base para busca de arquivos. | ||
256 | + | ||
257 | + Para vistualizar os logs de processamento do serviço, basta executar o seguinte comando: | ||
258 | + docker logs <NOME_CONTAINER> | ||
242 | \ No newline at end of file | 259 | \ No newline at end of file |