Ι have this Dockerfile:
FROM openjdk:11
ENV JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
The structure of my application is:
Demo:
--deployment:
--Dockerfile
--src/
--docker-compose.yaml
--target:
--app.jar
Code snippet from docker-compose file:
api:
container_name: backend
image: backend
build:
context: deployment/
ports:
- "8080:8080"
When I am putting the Dockerfile in the same directory with the docker-compose and I am changing the docker compose to:
api:
container_name: backend
image: backend
build: .
ports:
- "8080:8080"
Is running as expected. But I want to put the Dockerfile into the deployment folder, since there I have the helm chart and others docker-comopose files which are using this Dockerfile.
My question is:
How I can specify the correct path of the target folder in the Dockerfile?
CodePudding user response:
You cannot copy anything which is out of the build context. If you want to keep the current project structure a solution would be in your compose file for the api
service:
build:
context: .
dockerfile: deployment/Dockerfile