2

I'm getting stuck on a Dockerfile with:

[2/2] STEP 31/42: COPY /opt/SIMULATeQCD/src /simulateqcd/src
Error: error building at STEP "COPY /opt/SIMULATeQCD/src /simulateqcd/src": checking on sources under "/opt/SIMULATeQCD/podman-build": copier: stat: "/opt/SIMULATeQCD/src": no such file or directory

However, it does exist so I am baffled as to what podman is looking for:

[grant@simulateqcd podman-build]$ ls -al /opt/SIMULATeQCD/src
total 144
drwxr-xr-x. 12 grant grant  4096 Apr 14 16:23 .
drwxr-xr-x.  3 root  root     25 Apr 14 16:20 ..
-rw-r--r--.  1 grant grant 52854 Apr 14 16:09 CMakeLists.txt
-rwxr-xr-x.  1 grant grant   126 Apr 14 16:09 cmake.sh

I've spent the better part of 45 minutes playing with the context, checking the permissions, turning off SELinux, and am at a loss as to what else to check. I've given it an absolute path everywhere I can think to look but it still says the path doesn't exist.

Everything is owned by 1000:1000 everywhere. Context directory is /opt/SIMULATeQCD, Dockerfile is in /opt/SIMULATeQCD/podman-build. I'm running the Dockerfile like this:

      podman build \
        --tag simulateqcd/simulateqcd:latest \
        --label name=simulateqcd \
        --build-arg CORES=${CORES} \
        --build-arg RHEL_VERSION=${RHEL_VERSION} \
        --build-arg CUDA_VERSION=${CUDA_VERSION} \
        --build-arg USERNAME=${USERNAME} \
        --build-arg GROUPNAME=${GROUPNAME} \
        --build-arg USER_ID=${USER_ID} \
        --build-arg GROUP_ID=${GROUP_ID} \
        --build-arg DIRECTORY=$topdir \
        -f $scriptdir/Dockerfile
        /opt/SIMULATeQCD

Is there something else I'm missing maybe?

Update

The Dockerfile is here

COPY ./src /simulateqcd/src
COPY ./CMakeLists.txt /simulateqcd/CMakeLists.txt
COPY ./parameter /simulateqcd/parameter
COPY ./scripts /simulateqcd/scripts
COPY ./test_conf /simulateqcd/test_conf

The script is run from this line

      podman build \
        --tag simulateqcd/simulateqcd:latest \
        --label name=simulateqcd \
        --build-arg CORES=${CORES} \
        --build-arg RHEL_VERSION=${RHEL_VERSION} \
        --build-arg CUDA_VERSION=${CUDA_VERSION} \
        --build-arg USERNAME=${USERNAME} \
        --build-arg GROUPNAME=${GROUPNAME} \
        --build-arg USER_ID=${USER_ID} \
        --build-arg GROUP_ID=${GROUP_ID} \
        --build-arg ARCHITECTURE=${ARCHITECTURE} \
        --build-arg USE_GPU_AWARE_MPI=${USE_GPU_AWARE_MPI} \
        --build-arg USE_GPU_P2P=${USE_GPU_P2P} \
        --build-arg TARGET=${TARGET} \
        -f $scriptdir/Dockerfile
        $topdir

where $topdir = /opt/SIMULATeQCD and $scriptdir=/opt/SIMULATeQCD/podman-build. src is located at /opt/SIMUALTeQCD/src

Running ./simulateqcd build gets you:

Error: error building at STEP "COPY ./src /simulateqcd/src": checking on sources under "/opt/SIMULATeQCD/podman-build": copier: stat: "/src": no such file or directory
./simulate_qcd.sh: line 285: /opt/SIMULATeQCD: Is a directory
Grant Curell
  • 1,321
  • 2
  • 16
  • 32
  • The absolute path of your file is relative to the context of your build, not absolute in the real sense on the host. Try to bring the file you're copying aside the Dockerfile and do a relative COPY ./ to see if this works as a quick-fix – Neo Anderson Apr 14 '23 at 22:08
  • I think I started with that? I set context to /opt/SIMULATeQCD. The Dockerfile itself is in /opt/SIMULATeQCD/podman-build. I ran it from the podman-build directory with COPY ./file /SIMULATeQCD/file. `src` is in /opt/SIMULATeQCD/src. Is that in line with your suggestion? Note, it does work if I put the Dockerfile in the root directory and run it but I thought that was the point of that last line was to set the context of the build. – Grant Curell Apr 15 '23 at 10:01
  • You are setting the build context, but you have not shared the `Dockerfile`, or more precisely the `COPY` command from the `Dockerfile`. I assume the problem is there. I created a minimal example with Dockerfile and build context in different paths and posted as answer. – Neo Anderson Apr 15 '23 at 13:52

1 Answers1

2

The two relevant aspects for the question are the Dockerfile path, which can be provided with the -f option and the build context, which is the last argument in the build command.

When a context is set in the podman build command, all subsequent COPY instructions inside the Dockerfile are relative to the context path.

Assuming you have the following directory structure:

.
├── opt
│   └── SIMULATeQCD
│       └── src
│           ├── CMakeLists.txt
│           └── cmake.sh
└── scripts
    └── Dockerfile

If you run the build command like this:

podman build -f scripts/Dockerfile -t alpine-context-so-img opt/SIMULATeQCD/src/

Then the Dockerfile should COPY files as if the current working directory on the host machine was /opt/SIMULATeQCD/src:

FROM alpine:3.14
WORKDIR /target-path-in-container
# Next line is valid and also copies the two files
# COPY . . 
# But for better exemplification, I am copying each
# file verbosely:
COPY ./cmake.sh .
COPY ./CMakeLists.txt .
ENTRYPOINT [ "ls", "/target-path-in-container"]

Now if you run the container, the two files should be found in the container:

$ podman run alpine-context-so-img
CMakeLists.txt
cmake.sh
Neo Anderson
  • 5,957
  • 2
  • 12
  • 29
  • 1
    1) I really appreciate the help 2) I must be missing something obvious - it looks like that is what I'm doing exactly? I have put an update. I know this must be user error, but man I'm just not seeing it. – Grant Curell Apr 15 '23 at 18:58
  • 1
    I'm looking at my error again and am confused as to why it is looking at `podman-build` as the context even when I remove $topdir and specify /opt/SIMULATeQCD as the context to be 100% sure that is the context. I'm beginning to think there might be a bug? Or at least something misleading – Grant Curell Apr 15 '23 at 19:13
  • 1
    I figured it out. I am stupid. So incredibly stupid. I forgot a `\\` – Grant Curell Apr 15 '23 at 19:38