I'm actually setting up a devops environement using Github Actions and Microsoft Azure services. One of the steps i use in my pipeline is building a Docker image and pushing it to Azure Container Registry (ACR). To do that, i'm using the official action.
The problem is that when my Dockerfile is built , the server cannot find the path for the files i used in it.
To make it work, i tried to change the folder i passed to the action but with no result. Despite my Dockerfile is at the root of my project ( the default value in the action ), i get an error even when i'm explicitely giving the path.
I understood that the context of the server in which it runs is way different than mine. Knowing that in my workflow i build the project (to generate the JAR file) before trying to build the Docker image so the JAR file exists on the server which runs the workflow (Github server). I tried to debug the Build action, and the line which fails is 26 :
az acr build ..., i'm actually 99% sure that all arguments are correct, but i still get the context error.
I tried to understand by myself and searched in the Azure CLI documentation but couldn't find the information. So now the question i'm asking myself is : does the
az acr build run locally on the shell which called it (check scenario 1 image) ? or on an azure server which would explains why the server cannot find the JAR file (scenario 2) ?
And if it is scenario 2, is there a way to make pass the JAR file to az acr build and influence the server context ? Or should i ignore the official action and rewrite an action by myself which build the image locally not using the
az acr build command ?
My Dockerfile (Spring Boot project) :
COPY target/devOps-0.0.1-SNAPSHOT.jar devOps-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java", "-jar", "/devOps-0.0.1-SNAPSHOT.jar"]
The error i get :
Step 2/3 : COPY target/devOps-0.0.1-SNAPSHOT.jar devOps-0.0.1-SNAPSHOT.jar
COPY failed: file not found in build context or excluded by .dockerignore: stat target/devOps-0.0.1-SNAPSHOT.jar: file does not exist
2022/11/02 08:16:14 Container failed during run: build. No retries remaining.
failed to run step ID: build: exit status 1
Scenario 1 :
Scenario 2 :