0

Here's my Dockerfile that I want to use for one of my web-api using python fastapi, but whenever I try to built it, I am getting the below given error.

FROM tiangolo/uvicorn-gunicorn:python3.8

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get dist-upgrade -y && \
    apt-get autoremove -y && \
    apt-get clean && \
    apt-get autoclean && \
    apt-get install -y gcc make apt-transport-https ca-certificates build-essential

RUN apt-get install -y curl autoconf automake libtool pkg-config git
RUN git clone https://github.com/openvenues/libpostal

WORKDIR /libpostal
RUN ./bootstrap.sh
RUN libpostal/configure --datadir=/opt
RUN libpostal/make -j $(nproc)
RUN libpostal/make install && ldconfig



ENV PORT 8000
ENV APP_MODULE app.parser:app
ENV LOG_LEVEL debug
ENV WEB_CONCURRENCY 2

COPY ./requirements/base.txt ./requirements/base.txt
RUN pip install --no-cache-dir -r requirements/base.txt


COPY ./app /app/app

Whenever I run this I am getting this below error,

Sending build context to Docker daemon  4.262GB
Step 1/18 : FROM tiangolo/uvicorn-gunicorn:python3.8
 ---> 524e010ef786
Step 2/18 : ENV ENVIRONMENT staging
 ---> Using cache
 ---> d3e496ea9bbe
Step 3/18 : RUN apt-get update &&     apt-get upgrade -y &&     apt-get dist-upgrade -y &&     apt-get autoremove -y &&     apt-get clean &&     apt-get autoclean &&     apt-get install -y gcc make apt-transport-https ca-certificates build-essential
 ---> Using cache
 ---> cf3c1a8556e0
Step 4/18 : RUN apt-get install -y curl autoconf automake libtool pkg-config git
 ---> Using cache
 ---> 77879c6f66e9
Step 5/18 : RUN git clone https://github.com/openvenues/libpostal
 ---> Using cache
 ---> f1f7cf06e398
Step 6/18 : WORKDIR /libpostal
 ---> Running in 51191c3a69cb
Removing intermediate container 51191c3a69cb
 ---> d98ff97331db
Step 7/18 : RUN ./bootstrap.sh
 ---> Running in 40fd37f4900b
/bin/sh: 1: ./bootstrap.sh: not found
The command '/bin/sh -c ./bootstrap.sh' returned a non-zero code: 127

Please tell me what am I doing wrong in the Dockerfile?

2
  • What puts bootstrap.sh in /libpostal? Commented Feb 25, 2021 at 2:26
  • @kichik Git clone, clones the repo libpostal and inside it we will have the file bootstrap.sh Commented Feb 25, 2021 at 2:34

1 Answer 1

4

The default WORKDIR for your base image tiangolo/uvicorn-gunicorn:python3.8 is /app. I believe this is the Dockerfile for the base. When you cloned the repo, you were actually running it in /app.

You can explicitly set WORKDIR / or specify WORKDIR /app/libpostal to successfully run the bootstrap script.

You should also adjust your paths in the RUN commands after cloning since they should be relative. Here are the changes I suggest:

Option 1

# this command is run in the /app folder, a default set in the base image
RUN git clone https://github.com/openvenues/libpostal

WORKDIR /app/libpostal
RUN ./bootstrap.sh
RUN ./configure --datadir=/opt
RUN make -j $(nproc)
RUN make install && ldconfig

Option 2

# explicitly set working directory in root
WORKDIR /
RUN git clone https://github.com/openvenues/libpostal

WORKDIR /libpostal
RUN ./bootstrap.sh
RUN ./configure --datadir=/opt
RUN make -j $(nproc)
RUN make install && ldconfig
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.