Create a Docker image for PHP
Using Codefresh pipelines
Codefresh can work with PHP projects using any of the popular frameworks (Laravel, Symphony, CakePHp etc.)
The example PHP project
You can see the example project at https://github.com/codefresh-contrib/php-composer-sample-app. The repository contains a simple PHP project that uses composer as a package manager.
The dockerfile uses multi-stage builds to minimize the size of the docker image.
Create a Docker image for PHP project
An example pipeline is also offered in the git repository. It contains just two steps:
- A clone step to fetch the code
- A build step to create a Docker image
Once you run this pipeline Codefresh will create a Docker image for the Php application:
Notice that all dependencies are downloaded when the dockerfile is created.
Launch Docker images
Codefresh can also launch Docker images (using Docker swarm behind the scenes). With each Codefresh account you get access to a limited number of Docker environments that can host any Docker image or Docker compose file.
First find your images in the Docker image dashboard.
Click on the launch button and a new pipeline will run for deployment:
Notice that the pipeline logs show the dynamic URL of the application. Simply visit it with your browser and you will see the result.
Notice that these environments are only for testing and previewing your application as it is developed. They are NOT for production purposes.
Codefresh YAML for pipeline definitions
Steps in pipelines
How Codefresh pipelines work