When referring to a Dockerfile
in another folder, any instructions such as COPY
from the Dockerfile
will use the current directory instead of the directory of Dockerfile
when running, ultimately failing:
$ rg -N -A 1 build toml/vector.toml
[build]
dockerfile = "../docker/vector/Dockerfile"
$ cat docker/vector/Dockerfile
FROM timberio/vector:0.21.X-alpine
COPY vector.toml /etc/vector/
$ flyctl deploy -c toml/vector.toml
==> Verifying app config
--> Verified app config
==> Building image
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.13 linux x86_64
[+] Building 0.0s (0/1)
[+] Building 0.2s (5/5) FINISHED
=> [internal] load remote build context 0.0s
=> copy /context / 0.1s
=> [internal] load metadata for docker.io/timberio/vector:0.21.X-alpine 0.0s
=> [1/2] FROM docker.io/timberio/vector:0.21.X-alpine 0.0s
=> ERROR [2/2] COPY ./vector.toml /etc/vector/ 0.0s
------
> [2/2] COPY ./vector.toml /etc/vector/:
------
Error failed to fetch an image or build from source: error building: failed to compute cache key: "/vector.toml" not found: not found
Here’s my current file structure:
$ ls --tree
.
├── deploy
│ └── dashboard
│ ├── README.md
│ └── run.sh
├── docker
│ └── vector
│ ├── Dockerfile
│ └── vector.toml
├── docs
│ ├── grafana.md
│ ├── loki.md
│ └── vector.toml
├── toml
│ ├── grafana.toml
│ ├── loki.toml
│ └── vector.toml
It would be great if while building, the CWD changes to the path of the Dockerfile
.