Nur kopiert von irgendwo, mehr recherche notwenig:
In a nutshell: Code sollte direkt ins image, und nicht als volume gemountet werden (letzteres nur für development, aber nicht für tests und nicht für production).
If you want to always have the latest code built into the image for testing, you should avoid mounting the entire codebase as a volume in your Docker Compose configuration. Instead, rely on the build context to include your code in the image at build time. This way, any changes in your code will be incorporated into the image when you run docker-compose up --build.
Here's a refined approach:
Step-by-Step Approach
Remove Code Volume Mounting: Modify your docker-compose.yml to avoid mounting the entire codebase. Only mount specific configuration files if necessary.
Use Build Context and Dockerfile: Ensure your Dockerfile properly copies the code into the image.
Automate Rebuild and Test Execution: Use a script to handle tearing down old containers, rebuilding images, and running tests.
Nur kopiert von irgendwo, mehr recherche notwenig: In a nutshell: Code sollte direkt ins image, und nicht als volume gemountet werden (letzteres nur für development, aber nicht für tests und nicht für production).
If you want to always have the latest code built into the image for testing, you should avoid mounting the entire codebase as a volume in your Docker Compose configuration. Instead, rely on the build context to include your code in the image at build time. This way, any changes in your code will be incorporated into the image when you run docker-compose up --build.
Here's a refined approach: Step-by-Step Approach