![]() ![]() # This will download development/testing dependencies. # Copy only the files needed to download dependencies to avoid redownloading them when our code changes. # The dependencies are installed in the vendor folder that will later be copied. # In this image we will download the dependencies, but without the development dependencies. # Here we configure PHP, but this configuration will be overwritten for prod. # The pdo_mysql extension is required for both dev and prod.Ĭhown -R www-data:www-data /var/www/html \ # Use this image as the base image for dev and prod. Imagine the following scenario: you need certain tools installed on the Docker image that you will use for development, but you don’t want those tools on the final image that will be deployed in production.įor example, when developing in PHP it’s useful to have xdebug installed, but you normally don’t need it in production. You don’t need a Dockerfile for each environment One important thing is that we can name these stages to refer to them later on in the Dockerfile. Multi-stage builds allow us to use the FROM keyword in several places of the same Dockerfile.Įvery time we use the FROM keyword a new stage will be created. avoid having different Dockerfiles for every environment. ![]() ![]() In this post I’ll show you how to use multi-stage builds to: Even though this is being used more and more over time, there are still multi-stage patterns that are not that widely used. This allowed developers to build smaller Docker images by using a final stage containing the minimum required for the application to work. Docker released the multi-stage builds feature in the version 17.05. ![]()
0 Comments
Leave a Reply. |