0

docker build --pull -t "$DOCKER_REGISTRY_IMAGE" . ``` in my YML file it gives me the following error

#7 sha256:dfa2ef75c7954aaee8f870047cbaf47a407eb186847ff19b01de4c198fb4fa00
#7 ERROR: lstat /var/lib/docker/tmp/buildkit-mount254857695/build/libs: no such file or directory
------
 > [2/2] COPY build/libs/*.jar app.jar:
------
lstat /var/lib/docker/tmp/buildkit-mount254857695/build/libs: no such file or directory

When I run the same command in IntelliJ it works.

This is my YML file (The docker part)

deploy-docker:
  image: docker:latest
  stage: deploy-docker
  services:
    - docker:dind
  before_script:
    - docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PSW"
  script:
    - cd goatpool-backend
    - docker build --pull -t "$DOCKER_REGISTRY_IMAGE" .
    - docker push "$DOCKER_REGISTRY_IMAGE"

this is my Dockerfile content:

FROM openjdk:11
VOLUME /tmp
COPY build/libs/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
danielnelz
  • 3,794
  • 4
  • 25
  • 35
  • 1
    Very probably, it works locally but not in GitLab CI because you have a `./build/lib` directory in your local machine, while this directory wouldn't exist in (the fresh environment of) GitLab CI (?) – ErikMD Jun 09 '21 at 19:32
  • O of course. The build file is generated by Intellij. Let be see if I can build the jar file somewhere else. – Duarte Somsen Jun 09 '21 at 19:34
  • BTW note that your Dockerfile assumes the `*.jar` have been built *outside*, while it would be more idiomatic to run the `javac` or `mvn` command *inside* the container. See e.g. [this SO answer](https://stackoverflow.com/a/54299199/9164010) for an example Dockerfile. – ErikMD Jun 09 '21 at 19:35
  • Does this answer your question? [How to convert a Spring-Boot web service into a Docker image?](https://stackoverflow.com/questions/54269973/how-to-convert-a-spring-boot-web-service-into-a-docker-image) – ErikMD Jun 09 '21 at 19:35
  • I removed the "build/libs/" and now it works. I'm looking for a more permanent solution. – Duarte Somsen Jun 09 '21 at 19:38
  • Show us the code that produces the `*.jar`. – Alex Jun 10 '21 at 08:45

0 Answers0