Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

build docker image with non-root build context

Amit Prakash Singh March 21, 2021

Hello,

I have a repository that has 2 directories inside it. These 2 directories represent 2 separate docker projects.

Now with the bitbucket pipeline, I am trying to build the images but the build fails because Docker build context is not able to locate the files required for the build.

 

example:

pipelines:

    default:

         - parallel:

                - step:

                      script:

                           - docker build ${BITBUCKET_CLONE_DIR}/directory_1 --tag ${IMAGE_NAME}

 

 

 

# Dockerfile

# set base image (host OS)

FROM python:3.8
# set the working directory in the container

WORKDIR /code
# copy the dependencies file to the working directory

COPY requirements.txt .        ----- fails at this step


# install dependencies

RUN pip install --no-cache-dir -r requirements.txt


# copy the content of the local src directory to the working directory

COPY src/ .

# command to run on container

CMD [ "python", "./trsync.py" ]

 

Error:

COPY failed: stat /var/lib/docker/165536.165536/tmp/docker-builder235206778/requirements.txt: no such file or directory

 

 

I know this will work if I put the 2 docker projects in 2 different repo and keep the Dockerfile in repository root.

 

 

Thanks,

Amit

 

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 30, 2021

Hi @Amit Prakash Singh and welcome to the community.

I suspect the issue here may have to do with the location of the requirements.txt file and the working directory set in the Dockerfile.

In order to be able to better help you, could you please let me know:

1. I assume that you have the first Dockerfile inside directory_1?
2. What is the full path to requirements.txt file inside this repo?

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events