Hello there, the fact is I can build a docker image just fine using the usual command: “docker build -t project/spring_backend .”
But it doesn’t work for Fly.io when I try to launch it:
=> ERROR [2/2] COPY target/*.jar app.jar 0.0s
------
> [2/2] COPY target/*.jar app.jar:
------
Error: failed to fetch an image or build from source: error building: failed to solve: lstat /data/docker/tmp/buildkit-mount1012633289/target: no such file or directory
The dockerfile is the following:
FROM eclipse-temurin:21-jdk-alpine
VOLUME /tmp
COPY target/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
And the project structure is the following:
project
--src
--target
----generated.jar
--Dockerfile
--fly.toml
And the fly.toml just in case:
app = 'project'
primary_region = 'mad'
[build]
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']
[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
I have been doing research and troubleshooting this for hours now and I don’t know what is happening, my first guess is that the build that fly.io creates somehow places my project somewhere else, and so /target isn’t where it should be, but I am at a loss.
I would appreciate any and all help, have a good day!