diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 155cf44..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: circleci/php:7.0-apache - steps: - - checkout - - setup_remote_docker - - run: docker build -t mfieldhouse/docker-php-helloworld:$CIRCLE_BRANCH . - - diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..57997a6 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,24 @@ +name: CI +on: + push: + branches: + - dca +jobs: + docker: + runs-on: ubuntu-18.04 + steps: + - name: checkout + uses: actions/checkout@v2 + - name: test + run: | + set -x + docker build -t ramky/docker-php-helloworld:test . + docker run -d --name phpinfo -p 80:8080 ramky/docker-php-helloworld:test + while true + do sleep 10 + docker logs phpinfo 2>& 1 | grep 'PHP .* Development Server .* started' && break + done + while true + do sleep 10 + curl -s localhost | grep "PHP.*phpinfo()" && break + done diff --git a/Dockerfile b/Dockerfile index ccef55c..e670299 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,13 @@ -FROM php:7.0-apache -COPY src/ /var/www/html -EXPOSE 80 +FROM alpine +WORKDIR /app + +COPY src . + +RUN apk add php + +ENTRYPOINT ["php"] + +CMD ["-f","index.php","-S","0.0.0.0:8080"] + +EXPOSE 8080 diff --git a/README.md b/README.md index 229a183..0defebf 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,10 @@ # How it Works -Docker builds an image containing the application in src/ and all of its dependencies by using the Dockerfile contained in this repository. -The Dockerfile tells docker to use the [official PHP Docker image](https://hub.docker.com/_/php/) as the parent image. +## Setup -The PHP image then uses the [official Debian Jessie Docker image](https://hub.docker.com/_/debian/) as its parent image. +``` +docker build -t docker-php-helloworld . +docker run -p 80:80 docker-php-helloworld +``` -Debian then uses the [scratch image](https://hub.docker.com/_/scratch/) as its base image. - -At this point, an image has been built which contains Apache, PHP and all of the OS dependencies and libraries required to serve a webpage written in PHP. - -Finally, docker copies everything in src/ inside this repository to the /var/www/html folder inside the image. This is the Apache web root directory. - -# Setup - - - Ensure you have Docker installed - - `git clone` this repository - - `sudo docker build -t docker-php-helloworld .` - - `sudo docker run -p 80:80 docker-php-helloworld` - -# What You Should See - -![Docker PHP App](https://image.ibb.co/cTxSf7/whale.png "Hello World") - -This was originally created to test Amazon Elastic Container Service which is why Moby Dock says "Hello ECS!" diff --git a/src/index.php b/src/index.php index 3104b81..147cebc 100644 --- a/src/index.php +++ b/src/index.php @@ -1,7 +1 @@ -"; -echo "Hello ECS!
"; -echo ''; - -?> + diff --git a/src/other.php b/src/other.php new file mode 100644 index 0000000..a1e063b --- /dev/null +++ b/src/other.php @@ -0,0 +1,3 @@ +"; +?>