2017-10-13 3 views
0

Je suis en train de faire une api Tesseract en utilisant docker, mais quand au point de paquet installation je reçois cette erreur:Cant installer postgres sur docker avec rubis/sinatra

Fetching data_mapper 1.2.0 
Installing data_mapper 1.2.0 
Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

current directory: 
/var/lib/gems/2.3.0/gems/do_postgres-0.10.17/ext/do_postgres 
/usr/bin/ruby2.3 -r ./siteconf20171013-5-6l2bdy.rb extconf.rb 
checking for main() in -lpq... yes 
checking for libpq-fe.h... yes 
checking for libpq/libpq-fs.h... yes 
checking for postgres.h... no 
*** extconf.rb failed *** 
Could not create Makefile due to some reason, probably lack of necessary 
libraries and/or headers. Check the mkmf.log file for more details. You may 
need configuration options. 

Provided configuration options: 
    --with-opt-dir 
    --without-opt-dir 
    --with-opt-include 
    --without-opt-include=${opt-dir}/include 
    --with-opt-lib 
    --without-opt-lib=${opt-dir}/lib 
    --with-make-prog 
    --without-make-prog 
    --srcdir=. 
    --curdir 
    --ruby=/usr/bin/$(RUBY_BASE_NAME)2.3 
    --with-pgsql-server-dir 
    --without-pgsql-server-dir 
    --with-pgsql-server-include 
    --without-pgsql-server-include=${pgsql-server-dir}/include 
    --with-pgsql-server-lib 
    --without-pgsql-server-lib=${pgsql-server-dir}/lib 
    --with-pgsql-client-dir 
    --without-pgsql-client-dir 
    --with-pgsql-client-include 
    --without-pgsql-client-include=${pgsql-client-dir}/include 
    --with-pgsql-client-lib 
    --without-pgsql-client-lib=${pgsql-client-dir}/lib 
    --with-pqlib 
    --without-pqlib 
Could not find PostgreSQL build environment (libraries & headers): Makefile not 
created 

To see why this extension failed to compile, please check the mkmf.log which can 
be found here: 

    /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/do_postgres-0.10.17/mkmf.log 

extconf failed, exit code 1 

Gem files will remain installed in /var/lib/gems/2.3.0/gems/do_postgres-0.10.17 
for inspection. 
Results logged to 
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/do_postgres-0.10.17/gem_make.out 

An error occurred while installing do_postgres (0.10.17), and Bundler cannot 
continue. 
Make sure that `gem install do_postgres -v '0.10.17'` succeeds before bundling. 

In Gemfile: 
    dm-postgres-adapter was resolved to 1.2.0, which depends on 
    do_postgres 
The command '/bin/sh -c /bin/bash -l -c "bundle install"' returned a non-zero code: 5 

Mon fichier docker ressemble à ceci:

FROM ubuntu:16.04 

    RUN apt-get update && apt-get install -y \ 
     ruby-dev \ 
     postgresql postgresql-contrib libpq-dev \ 
     autoconf \ 
     autoconf-archive \ 
     automake \ 
     build-essential \ 
     checkinstall \ 
     cmake \ 
     g++ \ 
     git \ 
     libcairo2-dev \ 
     libcairo2-dev \ 
     libicu-dev \ 
     libicu-dev \ 
     libjpeg8-dev \ 
     libjpeg8-dev \ 
     libpango1.0-dev \ 
     libpango1.0-dev \ 
     libpng12-dev \ 
     libpng12-dev \ 
     libtiff5-dev \ 
     libtiff5-dev \ 
     libtool \ 
     pkg-config \ 
     wget \ 
     xzgv \ 
     zlib1g-dev \ 
     vim \ 
     python-pip 


    # SSH for diagnostic 
    RUN apt-get update && apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages openssh-server 
    RUN mkdir /var/run/sshd 
    RUN echo 'root:root' | chpasswd 
    RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config 
    # SSH login fix. Otherwise user is kicked off after login 
    RUN sed '[email protected]\s*required\s*[email protected] optional [email protected]' -i /etc/pam.d/sshd 
    ENV NOTVISIBLE "in users profile" 
    RUN echo "export VISIBLE=now" >> /etc/profile 

    EXPOSE 22 
    CMD ["/usr/sbin/sshd", "-D"] 

    # Directories 
    ENV SCRIPTS_DIR /home/scripts 
    ENV PKG_DIR /home/pkg 
    ENV BASE_DIR /home/workspace 
    ENV LEP_REPO_URL https://github.com/DanBloomberg/leptonica.git 
    ENV LEP_SRC_DIR ${BASE_DIR}/leptonica 
    ENV TES_REPO_URL https://github.com/tesseract-ocr/tesseract.git 
    ENV TES_SRC_DIR ${BASE_DIR}/tesseract 
    ENV TESSDATA_PREFIX /usr/local/share/tessdata 

    RUN mkdir ${SCRIPTS_DIR} 
    RUN mkdir ${PKG_DIR} 
    RUN mkdir ${BASE_DIR} 
    RUN mkdir ${TESSDATA_PREFIX} 

    COPY ./container-scripts/* ${SCRIPTS_DIR}/ 
    RUN chmod +x ${SCRIPTS_DIR}/* 
    RUN ${SCRIPTS_DIR}/repos_clone.sh 
    RUN ${SCRIPTS_DIR}/tessdata_download.sh 

    # Install pytesseract 
    RUN pip install --upgrade pip \ 
     && pip install pytesseract==0.1.6 

    # Add textcleaner from Fred's ImageMagick Scripts 
    # http://www.fmwconcepts.com/imagemagick/textcleaner/ 
    ADD ./bin/textcleaner /usr/local/bin 

    # Setup app 

    WORKDIR /app 

    ADD . /app 
    RUN /bin/bash -l -c "gem install pg -- --with-pg-lib=/usr/lib" 
    RUN /bin/bash -l -c "gem install bundler" 
    RUN /bin/bash -l -c "bundle install" 

    ENTRYPOINT ["ruby", "app.rb"] 

    # create user tesseract for use with this server 
    RUN groupadd -r tesseract && useradd -r -g tesseract tesseract 
    USER tesseract 

Je suis juste une petite application en cours d'exécution avec un seul sinatra point final où vous envoyez l'image un, il renvoie le texte en tant que fichier JSON et im trébuchant à ce stade. J'ai parcouru une bonne quantité de googled et essayé quelques solutions telles que pointer vers où le fichier de configuration est, mais ils semblent tous donner une erreur similaire.

Toute aide serait grande

+0

Le message d'erreur indique que la réponse peut être trouvée dans /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/ do_postgres-0.10.17/mkmf.log. Vous devriez poster le contenu de ce fichier. Je suppose qu'il vous manque des composants de construction essentiels; bibliothèques, outils, en-têtes, ce genre de choses. La réponse sera dans ce journal de construction. – Casper

+0

alors quand j'ai essayé d'ouvrir ce fichier, j'ai eu la réponse qu'il n'existe pas – Wrumble

Répondre

0

Pourquoi utiliser ubuntu: 16,04 tout en premier lieu. Je pense que le problème est que votre environnement docker n'a pas été correctement configuré pour exécuter ruby ​​et bundler. Pour surmonter ce processus d'installation sanglant, je vous suggère d'utiliser une image rubis avec une étiquette alpine ou mince si l'espace de stockage est un problème. Ensuite, le processus d'installation devient beaucoup plus facile et vous évitez toutes ces erreurs