Relative path in docker image step

Hi there,

I wanted to copy some files into docker-entrypoint-initdb.d within Dockerfile.

Folder structure:


- dbcontainer
    - Dockerfile
    - init.sql
- src
   - main
      - resources
         - dbmigration
            - schema.sql

Dockerfile

FROM xxxxx/base-images/postgres:latest

COPY /init.sql  /docker-entrypoint-initdb.d/
COPY /src/main/resources/dbmigration/*.sql /docker-entrypoint-initdb.d/

Codefresh step

name: db_docker_build_image
stage: test
type: build
tag: 'xxxx'
registry: my-docker-gcp-artifactory
title: Building Docker image for testing with DB container
working_directory: 'myProject/dbcontainer'
image_name: 'my_image/my_project'
dockerfile: Dockerfile

However I get melow mentioned error in the second copy line
error:

Step 6/12 : COPY /src/main/resources/dbmigration/*.sql /docker-entrypoint-initdb.d/                                                                             
[2023-10-28T08:48:26.780Z] COPY failed: no source files were specified

I hope by deafult command runs from the project root folder

tried with dot as well, no luck though
COPY ./src/main/resources/dbmigration/*.sql /docker-entrypoint-initdb.d/

I know having all necessacry files in the same folder where Dockerfile is in will work here.

Just wondering whether there is any option in codefresh above step to do this?

Local machine below setup works

FROM xxxxx/base-images/postgres:latest

COPY /dbcontainer/init.sql  /docker-entrypoint-initdb.d/
COPY /src/main/resources/dbmigration/*.sql /docker-entrypoint-initdb.d/

Run below from project root folder
docker build . -t my_db:v1.0 -f dbcontainer/Dockerfile

The codefresh step sets as working dir

myProject/dbcontainer

This means that only files under this folder are sent to the docker daemon. So nothing under src is sent.

To replicate the same thing you did locally, please use as working directory “myproject”

Does that mean there is no way of copying files from some other project location in this step?

You can send to the docker daemon anything that is under the directory that is used as context.
This is the same thing that you did locally.

This is how the Docker daemon works and Codefresh has the same behavior Build context | Docker Docs