Permalink
Browse files

speed up building by installing PHP 7.2 on Ubuntu 16.04

PHP 7.2 is the latest stable version of PHP and has many new features,
improvements, and bug fixes. You should definitely use it if you want
a better, faster website/application.
  • Loading branch information...
gjero
gjero committed Jul 5, 2018
1 parent 624c091 commit 0812a2474abd4a2fba7676d8bc94735229c0e8a2
Showing with 21 additions and 33 deletions.
  1. +15 −26 Dockerfile
  2. +1 −1 README.md
  3. +2 −2 build.sh
  4. +3 −4 sweep.sh
@@ -1,46 +1,35 @@
## Base image
FROM ubuntu:16.04

# Fixes some weird terminal issues
ENV TERM=linux
ENV APP_ENV=prod

## Copy modified PHP files into container
COPY . /php-react

## Set working directory
WORKDIR /php-react

# Add PHP 7.0
RUN cat /etc/debian_version \
&& apt-get update -y \
&& apt-get install -y --no-install-recommends wget curl \
&& apt-get update -y \
&& apt-get install -y php7.0 php7.0-curl php7.0-json php7.0-mbstring php7.0-zip php7.0-intl php7.0-dom php7.0-phar php7.0-pdo php7.0-sqlite3 \
&& wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig \
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php'); unlink('installer.sig');" \
&& php composer.phar update \
&& php composer.phar require "codeception/codeception:*" \
&& php composer.phar dump-autoload --optimize \
&& php composer.phar install

# Sweep unused data from the image
RUN apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends wget curl software-properties-common python-software-properties \
&& LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php \
&& apt-get update -y

RUN apt-get install -y php7.2 \
&& apt-get install -y php-pear php7.2-curl php7.2-dev php7.0-json php7.2-mbstring php7.2-zip php7.2-xml php7.2-pdo php7.2-sqlite3 php7.2-intl

RUN curl -s https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer \
&& composer update \
&& composer dump-autoload --optimize \
&& composer install

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

## Create SQLite table
RUN chmod +x create-table.php
RUN php create-table.php

## Expose port
EXPOSE 1337

## Set a volume for SQLite database
VOLUME /php-react/app/Articles/_database

RUN chmod +x run-server.php

## Run the reactive API server
ENTRYPOINT php run-server.php
@@ -59,7 +59,7 @@ DELETE | 404 (Not Found) or 405 (Method NOt Allowed)
```

## Benchmark Results
## Benchmark Results, over 19500 requests completed per second

[vagrant@gkrsteski php-reactor]$ loadtest http://10.0.49.227:5501/articles/10 -t 20 -c 20 --rps 1000
[Wed Feb 10 2016 12:24:47 GMT+0100 (CET)] INFO Requests: 0, requests per second: 0, mean latency: 0 ms
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

docker build -t reactphp-pimf-api:latest .
docker run -d -p 1337:1337 --name=reactphp-pimf-api-container reactphp-pimf-api:latest
docker build -t reactphp-pimf-api .
docker run -d -p 1337:1337 --name=reactphp-pimf-api-container reactphp-pimf-api
@@ -1,6 +1,5 @@
#!/usr/bin/env bash

docker stop reactphp-pimf-api:latest
docker rm -f reactphp-pimf-api:latest
image_id=$(docker inspect --format="{{.Id}}" reactphp-pimf-api:latest)
docker rmi -f ${image_id}
docker stop reactphp-pimf-api-container
docker rm -f reactphp-pimf-api-container
docker rmi -f $(docker inspect --format="{{.Id}}" reactphp-pimf-api:latest)

0 comments on commit 0812a24

Please sign in to comment.