Skip to content

Commit

Permalink
add simple php example
Browse files Browse the repository at this point in the history
  • Loading branch information
Don Townsend committed Oct 12, 2020
1 parent 6de729b commit f49bf2e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
15 changes: 15 additions & 0 deletions example-php-apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SEE: https://hub.docker.com/_/php
FROM php:7.2-apache
LABEL maintainer="[email protected]"

# 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/
24 changes: 24 additions & 0 deletions example-php-apache/README.md
Original file line number Diff line number Diff line change
@@ -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: `<MACHINE_PORT>:<CONTAINER_PORT>`
- `-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)
2 changes: 2 additions & 0 deletions example-php-apache/src/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
echo "Hello world";

0 comments on commit f49bf2e

Please sign in to comment.