Giter Site home page Giter Site logo

ssiwan / php-docker-apache-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fuhrysteve/php-docker-apache-example

0.0 1.0 0.0 11 KB

Just a simple example of how to create a simple PHP application and deploy it with Docker

Dockerfile 39.81% PHP 60.19%

php-docker-apache-example's Introduction

Example of a PHP web application using Docker

How does it work?

# build the docker image
docker build -t php-docker-apache-example .

# run the docker container on this machine. Expose its internal
# port 80 to this machine's port 8080
docker run -d -p 8080:80 php-docker-apache-example

And you can see the result here: screenshot

# to spin up additional containers on different ports, you might
# do something like this:
docker run -d -p 5000:80 php-docker-apache-example
docker run -d -p 5001:80 php-docker-apache-example
docker run -d -p 5002:80 php-docker-apache-example
docker run -d -p 5003:80 php-docker-apache-example
docker run -d -p 5004:80 php-docker-apache-example
docker run -d -p 5005:80 php-docker-apache-example
docker run -d -p 5006:80 php-docker-apache-example
docker run -d -p 5007:80 php-docker-apache-example

Now you have 8 concurrent webservers running, all ready to serve traffic on 8 different ports. A load balancer would typically choose which container to send a request to based on load / availability / etc.

If you wanted to deploy a new version of your software but are nervous of breaking something, you could spin up new containers and leave the old ones running. If anything bad happens, switching back to the old containers is quick and reliable.

More information

  • The PHP application code goes in myapp/
  • The first line of the Dockerfile FROM php:7.0-apache means "use the official maintained image (which happens to be debian based) with php version 7 and apache installed on it". When you rebuild your images, you get any security updates along with it for free.
  • Developers are typically responsible for creating and maintaining the Dockerfile and any dependencies their code makes use of (for example, if they want to use ImageMagick to convert images to thumbnails, they will have to put it in the Dockerfile, otherwise their code would break).
  • Applications should avoid writing to the filesystem (when uploading files, for instance) and prefer to use object storage, such as Amazon S3 instead. The reason for this is that it is a maintenance headache. It is definitely possible. It is usually more annoying than alternatives.
  • In development, the developer would likely also use a docker container for MySQL / similar persistent data stores. In production, their Docker container would likely connect to a different (managed) database.

php-docker-apache-example's People

Contributors

fuhrysteve avatar

Watchers

Shamal Siwan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.