Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple docker environment #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM php:7.1.9-apache

ARG GITHUB_OAUTH_TOKEN

ENV COMPOSER_NO_INTERACTION=1 \
COMPOSER_ALLOW_SUPERUSER=1 \
PATH=/root/.composer/vendor/bin:$PATH

RUN apt-get -qy update && \
apt-get -qy install \
git \
zlib1g-dev \
libicu-dev \
&& \
apt-get -qy clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN docker-php-ext-configure \
intl \
&& \
docker-php-ext-install -j$(nproc) \
zip \
intl

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
composer config -g github-oauth.github.com ${GITHUB_OAUTH_TOKEN} && \
composer global require hirak/prestissimo

WORKDIR /var/www/html/php-framework-benchmark
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ If you want to see current configuration, run `sudo sysctl -a`.
</VirtualHost>
~~~

## Docker Environment
- You need only `docker` and `docker-compose` installed
- Run `$ GITHUB_OAUTH_TOKEN=<your-github-oauth-token> docker-compose up --build` (for Composer installs and avoid GitHub API Rate limits)
- Go to inside the container: `$ docker exec -it php-framework-benchmark bash`

## References

* [Aura](http://auraphp.com/) ([@auraphp](https://twitter.com/auraphp))
Expand Down
4 changes: 3 additions & 1 deletion benchmarks/_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ benchmark ()
rps=`grep "Requests per second:" "$ab_log" | cut -f 7 -d " "`

# get time
i=0
count=10
total=0
for ((i=0; i < $count; i++)); do
while [ "$i" -le $count ]; do
curl "$url" > "$output"
t=`tail -1 "$output" | cut -f 2 -d ':'`
total=`php ./benchmarks/sum_ms.php $t $total`
i=$(( i + 1 ))
done
time=`php ./benchmarks/avg_ms.php $total $count`

Expand Down
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "2"
services:
app:
build:
context: .
args:
- GITHUB_OAUTH_TOKEN=${GITHUB_OAUTH_TOKEN}

container_name: php-framework-benchmark

volumes:
- .:/var/www/html/php-framework-benchmark:cached

ports:
- "80:80"
2 changes: 1 addition & 1 deletion laravel-5.3/_benchmark/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

composer install --no-dev --optimize-autoloader
chmod o+w storage/*
sudo chmod o+w storage/framework/*
chmod o+w storage/framework/*
php artisan optimize --force
php artisan config:cache
php artisan route:cache
2 changes: 1 addition & 1 deletion staticphp-0.9/_benchmark/setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

sudo rm -rf Application/Cache/*
rm -rf Application/Cache/*
composer install --no-interaction --no-dev --optimize-autoloader

chmod 777 -R Application/Cache/