-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Don Townsend
committed
Oct 12, 2020
1 parent
6de729b
commit f49bf2e
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
echo "Hello world"; |