From f49bf2e74670490e928e91544fe1d04b53d61197 Mon Sep 17 00:00:00 2001 From: Don Townsend Date: Mon, 12 Oct 2020 11:39:48 -0400 Subject: [PATCH] add simple php example --- example-php-apache/Dockerfile | 15 +++++++++++++++ example-php-apache/README.md | 24 ++++++++++++++++++++++++ example-php-apache/src/index.php | 2 ++ 3 files changed, 41 insertions(+) create mode 100644 example-php-apache/Dockerfile create mode 100644 example-php-apache/README.md create mode 100644 example-php-apache/src/index.php diff --git a/example-php-apache/Dockerfile b/example-php-apache/Dockerfile new file mode 100644 index 0000000..272feaf --- /dev/null +++ b/example-php-apache/Dockerfile @@ -0,0 +1,15 @@ +# SEE: https://hub.docker.com/_/php +FROM php:7.2-apache +LABEL maintainer="builders@teamairship.com" + +# expose port 80 for http:// +EXPOSE 80 + +# expose port 443 for https:// +EXPOSE 443 + +# copy all files from src directory +COPY src/ /var/www/html/ + +# allow changes to auto-populate when running local dev environment +VOLUME src/ /var/www/html/ diff --git a/example-php-apache/README.md b/example-php-apache/README.md new file mode 100644 index 0000000..d769b31 --- /dev/null +++ b/example-php-apache/README.md @@ -0,0 +1,24 @@ +# Docker - simple PHP server + +Follow these steps to start the php server: + +``` +cd /path/to/example-php-apache +docker build -t example-php-apache-img . +docker run -p 3000:80 -v $(pwd)/src:/var/www/html --name example-php-apache-container example-php-apache-img +``` + +Open up the following url in your browser: + +- http://localhost:3000 + + +# Notes + +In the `docker run` command: +- `-p` maps ports like so: `:` +- `-v` specifies the volume to enable realtime updates in local dev environment. + - The volume must be specified at runtime in order for this to work. [See documentation](https://docs.docker.com/engine/reference/builder/#notes-about-specifying-volumes) for more details. + - The host volume mount src MUST be absolute, not relative + - `$(pwd)` just outputs the absolute path of the present working directory + - Volumes have ZERO effect once deployed (except for sharing filesystems across several containers) diff --git a/example-php-apache/src/index.php b/example-php-apache/src/index.php new file mode 100644 index 0000000..f7a0588 --- /dev/null +++ b/example-php-apache/src/index.php @@ -0,0 +1,2 @@ +