https://pantsbuild.org/ logo
#general
Title
# general
t

tall-truck-67859

12/15/2021, 10:51 AM
Hi ! Sorry noob question again : I have a docker image built locally that I want to use with Minikube. When I tried to rebuild it after setting up env variable with
eval $(minikube docker-env)
and try to pants package the dockerfile again, I have this :
Copy code
ProcessExecutionFailure: Process 'Building docker image recital/n20-dev:latest.' failed with exit code 1.
stdout:
stderr:
2021/12/13 16:15:16 http2: server: error reading preface from client 192.168.49.2:2376: bogus greeting "Client sent an HTTP requ"
read tcp 192.168.49.1:38404->192.168.49.2:2376: read: connection reset by peer
I assume that I have to change docker context in pants.toml (DOCKER_HOST value in [docker]) but I still get the same error.
Docker built . -t {imagetag:version}
doesn’t work either. Thanks for help 🙂
c

curved-television-6568

12/15/2021, 11:00 AM
Hi 🙂 Do I understand you correctly that if you run
docker build …
directly from your terminal, that it doesn’t work? In that case, getting that to work first, is probably a good first step. What is the error output in that case?
t

tall-truck-67859

12/15/2021, 11:02 AM
Thanks for your answer @curved-television-6568. I have this :
Copy code
>  docker build --tag recital/n20-dev .
[+] Building 0.0s (2/2) FINISHED                                                                                                                                                     
 => [internal] load build definition from Dockerfile                                                                                                                            0.0s
 => => transferring dockerfile: 2B                                                                                                                                              0.0s
 => CANCELED [internal] load .dockerignore                                                                                                                                      0.0s
 => => transferring context:                                                                                                                                                    0.0s
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount003739442/Dockerfile: no such file or directory
c

curved-television-6568

12/15/2021, 11:04 AM
OK, so you don’t seem to have a
Dockerfile
in you current directory.. do you use a Dockerfile, or
instructions
on your
docker_image
target?
t

tall-truck-67859

12/15/2021, 11:10 AM
Yes it doesn't find any dockerfile. The one I'm trying to get is located in services/n20/Dockerfile : Dockerfile:
Copy code
FROM python:3.8

ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

WORKDIR /app

RUN apt-get update && apt-get clean \
    && apt-get install -y --no-install-recommends libopenjp2-7-dev \
    libgdk-pixbuf2.0-dev \
    cmake \
    make \
    wget \
    g++ \
    libjpeg-dev \
    libopenjp2-7-dev \
    libfreetype6-dev \
    libfontconfig1-dev \
    default-libmysqlclient-dev \
    libtiff5-dev \
    libomp-dev \
    libopenblas-dev \
    qpdf \
    # OCR LIBS
    tesseract-ocr libtesseract-dev libleptonica-dev pkg-config \
    imagemagick tesseract-ocr-fra ghostscript

RUN apt update \
    && apt -y install -qq git cmake autotools-dev libopenjp2-7-dev libtiff5-dev libpng-dev libgif-dev libxt-dev autoconf automake libtool bzip2 libxml2-dev libuninameslist-dev libspiro-dev python-dev libpango1.0-dev libcairo-dev chrpath uuid-dev uthash-dev software-properties-common libpoppler-private-dev libpoppler-glib-dev wget
RUN wget <https://poppler.freedesktop.org/poppler-0.89.0.tar.xz> \
    && tar xvf poppler-0.89.0.tar.xz \
    && cd poppler-0.89.0 \
    && mkdir build \
    && cd build \
    && cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DTESTDATADIR=$PWD/testfiles \
    -DENABLE_UNSTABLE_API_ABI_HEADERS=ON \
    .. \
    && make \
    && make install \
    && cd ../..

RUN apt update && apt install libreoffice unoconv -y

RUN python -m pip install nltk==3.6.2 && python -m nltk.downloader punkt && python -m nltk.downloader stopwords

COPY services/n20/resources /resources
COPY n20-*.whl .

RUN --mount=type=secret,id=pipconfig,dst=/etc/pip.conf \
    python -m pip install --no-cache-dir n20-*.whl && \
    rm n20-*.whl

RUN sed -i_bak 's/rights="none" pattern="PDF"/rights="read | write" pattern="PDF"/'i /etc/ImageMagick-6/policy.xml
RUN wget <https://github.com/DoubangoTelecom/tesseractMRZ/raw/master/tessdata_best/mrz.traineddata> -P /usr/share/tesseract-ocr/4.00/tessdata
RUN wget <https://github.com/tesseract-ocr/tessdata/raw/4.00/lat.traineddata> -P /usr/share/tesseract-ocr/4.00/tessdata
and in the build file (located at services/n20) :
Copy code
docker_image(
    name="n20",
    dependencies=["src/python/n20:wheel", ":resources"],
    image_tags=["{build_args.BITBUCKET_BUILD_NUMBER}"],
    extra_build_args=["--secret id=pipconfig,src=pip.conf"],
    repository="recital/n20-dev",
)

files(
    name="resources",
    sources=["resources/*"],
)
(sorry for the huge post)
👍 1
c

curved-television-6568

12/15/2021, 11:15 AM
so you’d want to run this from your project root:
Copy code
docker build -t recital/n20-dev -f services/n20/Dockerfile .
and make sure to have your
.dockerignore
properly skip files you don’t need, so you don’t get Gb of build context… 😉
🙏 1
t

tall-truck-67859

12/15/2021, 11:38 AM
Thanks !! I'm going to try this
👍 1
c

curved-television-6568

12/15/2021, 11:43 AM
When that works (or at least, docker attempts to build, but maybe fail due to missing dependencies, such as wheel files) we can try to get it to work using
./pants package
🙂
🙏 2
t

tall-truck-67859

12/15/2021, 11:47 AM
ha yes ! Indeed I have a .whl that missing after starting building correctly :
c

curved-television-6568

12/15/2021, 12:11 PM
OK, so back to minikube, look at what
minikube docker-env
tells you, and put those env vars into your
pants.toml
file under
[docker].env_vars
(with just the names, as it will pick up the values from your env)
t

tall-truck-67859

12/15/2021, 12:15 PM
ok thanks you very much again 🙂
Ok problem solved ! I'm able to deploy my Charts. Thank for taking time to explain and help me on each step 🙂
💯 2
c

curved-television-6568

12/15/2021, 1:32 PM
Your’re welcome. Happy it works! 😄
❤️ 1
7 Views