Configure Dockerfile & Context
dockerfile
The dockerfile option expects a string with a path to a Dockerfile.
- The path in
dockerfileshould be relative to thedevspace.yaml. - When setting the
dockerfileoption, it is often useful to set thecontextoption as well. - To share your configuration with team mates, make sure
devspace.yamland allDockerfilesused in theimagessection are checked into your code repository.
Default Value For dockerfile
dockerfile: ./Dockerfile
Example: Different Dockerfile
images:
backend:
image: john/appbackend
frontend:
image: john/appfrontend
dockerfile: frontend/Dockerfile
context: frontend/
Explanation:
- The first image would be built using the Dockerfile in
./Dockerfileand the context path./. - The second image would be built using the Dockerfile in
./frontend/Dockerfileand the context path./frontend/. - Switching the
contextfor imagefrontendwould assure that a statement likeADD file.txtorCOPY file.txt .in./frontend/Dockerfilewould use the local file./frontend/file.txtinstead of./file.txt. - In this example, it would probably be useful to have a
./.dockerignorefile which ignores thefrontend/folder when building the first image calledbackend.
note
See Best Practices for Image Building for details on how to optimize your Dockerfiles and use .dockerignore for faster image building.
context
The context option expects a string with a path to the folder used as context path when building the image. The context path serves as root directory for Dockerfile statements like ADD or COPY.
What does "context" mean in terms of image building?
Default Value For context
context: ./
