mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-08 06:56:33 +02:00
Merge pull request #453 from maglnet/docker
add docker information / introduce virtualisation section
This commit is contained in:
14
_posts/13-01-01-Virtualization.md
Normal file
14
_posts/13-01-01-Virtualization.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
anchor: virtualization
|
||||
---
|
||||
|
||||
# Virtualization
|
||||
|
||||
Running your application on different environments in development and production can lead to strange bugs
|
||||
popping up when you go live. It's also tricky to keep different development environments up to date with the same
|
||||
version for all libraries used when working with a team of developers.
|
||||
|
||||
If you are developing on Windows and deploying to Linux (or anything non-Windows) or are developing in a team, you
|
||||
should consider using a virtual machine.
|
||||
This sounds tricky, but besides the widely known virtualization environments like VMware or VirtualBox, there are
|
||||
additional tools that may help you setting up a virtual environment in a few easy steps.
|
@@ -5,13 +5,9 @@ anchor: vagrant
|
||||
|
||||
## Vagrant {#vagrant_title}
|
||||
|
||||
Running your application on different environments in development and production can lead to strange bugs
|
||||
popping up when you go live. It's also tricky to keep different development environments up to date with the same
|
||||
version for all libraries used when working with a team of developers.
|
||||
|
||||
If you are developing on Windows and deploying to Linux (or anything non-Windows) or are developing in a team, you
|
||||
should consider using a virtual machine. This sounds tricky, but by using [Vagrant][vagrant] you can set up a simple
|
||||
virtual machine with only a few steps. These base boxes can then be set up manually, or you can use "provisioning"
|
||||
[Vagrant][vagrant] helps you building your virtual boxes on top of the known virtual environments and will configure
|
||||
these environments based on a single configuration file.
|
||||
These boxes can be set up manually, or you can use "provisioning"
|
||||
software such as [Puppet][puppet] or [Chef][chef] to do this for you. Provisioning the base box is a great way to
|
||||
ensure that multiple boxes are set up in an identical fashion and removes the need for you to maintain complicated
|
||||
"set up" command lists. You can also "destroy" your base box and recreate it without many manual steps, making it
|
||||
@@ -27,7 +23,7 @@ If you need a little help to start using Vagrant there are some services that mi
|
||||
- [Rove][rove]: service that allows you to pre-generate typical Vagrant builds, PHP among the options. The
|
||||
provisioning is made with Chef.
|
||||
- [Puphpet][puphpet]: simple GUI to set up virtual machines for PHP development. **Heavily focused in PHP**. Besides
|
||||
local VMs, can be used to deploy to cloud services as well. The provisioning is made with Puppet.
|
||||
local VMs, it can be used to deploy to cloud services as well. The provisioning is made with Puppet.
|
||||
- [Protobox][protobox]: is a layer on top of vagrant and a web GUI to setup virtual machines for web development. A single YAML document controls everything that is installed on the virtual machine.
|
||||
- [Phansible][phansible]: provides an easy to use interface that helps you generate Ansible Playbooks for PHP based projects.
|
||||
|
42
_posts/13-03-01-Docker.md
Normal file
42
_posts/13-03-01-Docker.md
Normal file
@@ -0,0 +1,42 @@
|
||||
---
|
||||
isChild: true
|
||||
anchor: docker
|
||||
---
|
||||
|
||||
## Docker {#docker_title}
|
||||
|
||||
Beside using Vagrant, another easy way to get a virtual development or production environment up and running is [Docker][docker].
|
||||
Docker helps you to provide Linux containers for all kind of applications.
|
||||
There are many helpful docker images which could provide you with other great services without the need to install
|
||||
these services on your local machine, e.g. MySQL or PostgreSQL and a lot more.
|
||||
Have a look at the [Docker Hub Registry][docker-hub] to search a list of available pre-built containers,
|
||||
which you can then run and use in very few steps.
|
||||
|
||||
### Example: Runnning your PHP Applications in Docker
|
||||
After you [installed docker][docker-install] on your machine, you can start an Apache with PHP support in one step.
|
||||
The following command will download a fully functional Apache installation with the latest PHP version and provide the
|
||||
directory `/path/to/your/php/files` at `http://localhost:8080`:
|
||||
|
||||
{% highlight bash %}
|
||||
docker run -d --name my-php-webserver -p 8080:80 -v /path/to/your/php/files:/var/www/html/ php:apache
|
||||
{% endhighlight %}
|
||||
|
||||
After running `docker run` your container is initialized and running.
|
||||
If you would like to stop or start your container again, you can use the provided name attribute and simply run
|
||||
`docker stop my-php-webserver` and `docker start my-php-webserver` without providing the above mentioned parameters again.
|
||||
|
||||
### Learn more about Docker
|
||||
The commands mentioned above only show a quick way to run an Apache web server with PHP support but there are a lot more
|
||||
things that you can do with Docker.
|
||||
One of the most important things for PHP developers will be linking your web server to a database instance, for example.
|
||||
How this could be done is well described within the [Docker User Guide][docker-doc].
|
||||
|
||||
* [Docker Website][docker]
|
||||
* [Docker Installation][docker-install]
|
||||
* [Docker Images at the Docker Hub Registry][docker-hub]
|
||||
* [Docker User Guide][docker-doc]
|
||||
|
||||
[docker]: http://docker.com/
|
||||
[docker-hub]: https://registry.hub.docker.com/
|
||||
[docker-install]: https://docs.docker.com/installation/
|
||||
[docker-doc]: https://docs.docker.com/userguide/
|
Reference in New Issue
Block a user