Podman build can't find app.py in the specified folder

26 views Asked by At

I am at my first hands on practice with trying to deploy my model on GCloud and I am using podman. When I try to build the container with podman build -t default-service-fastpai:latest . , I get an error at STEP 6/9

STEP 6/8: COPY app /
Error: building at STEP "COPY app /": checking on sources under "Documents/Projects/Pred_default/app": copier: stat: "/app": no such file or directory

The folder is formatted as follows:

└── Pred_default
    └── app
        └── Containerfile
        └── app.py
        └── app_test.py
        └── lgb_credit_model.pkl
        └── lgb_es_model.pkl
        └── measure_response.py
        └── requirements.txt
    └── .gitignore
    └── LICENSE.md
    └── README.md
    └── credit_predict.ipynb
    └── requirements.txt

And this is the Containerfile. I am not sure what is going wrong, the app.py is right there, why can't podman see it?

FROM python:3.10-slim

RUN mkdir /app
# Set the working directory
WORKDIR /app

# Copy the requirements file into the container
COPY requirements.txt requirements.txt

# Install the required packages
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

# Copy the application code into the container
COPY app /
# COPY ["lgb_credit_model.pkl", "lgb_es_model.pkl" "app.py", "./"] 

# Expose the app port
EXPOSE 80

# Run command
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "80"]
1

There are 1 answers

1
helpinghand On BEST ANSWER

From the error you shared and your Containerfile, it seems the issue is due to the fact that the COPY command in your Containerfile cannot find the app directory within the specified context. It tries to copy the app directory to the root directory (/) of the container, but it seems like you might want to copy it into the /app directory you created inside the container.

Change the COPY command in your Containerfile from:

COPY app /

to:

COPY app/ /app/

This should correctly copy the contents of your local app directory into the /app directory inside the container.

Also make sure to run the podman build command from the Pred_default directory, where the app directory is located.