-
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
Showing
14 changed files
with
320 additions
and
61 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
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,16 @@ | ||
.PHONY: all rr fpm builtin apache | ||
|
||
%.Dockerfile: | ||
docker build -f $@ -t symfony-demo:$(basename $@) . | ||
|
||
rr.Dockerfile: base.Dockerfile | ||
fpm.Dockerfile: base.Dockerfile | ||
builtin.Dockerfile: base.Dockerfile | ||
apache.Dockerfile: base.Dockerfile | ||
|
||
rr: rr.Dockerfile | ||
fpm: fpm.Dockerfile | ||
builtin: builtin.Dockerfile | ||
apache: apache.Dockerfile | ||
|
||
all: rr fpm builtin |
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 @@ | ||
FROM php:7.4-apache | ||
|
||
RUN apt-get update && apt-get -y install libicu-dev libzip-dev && \ | ||
docker-php-ext-install bcmath intl opcache zip sockets; | ||
|
||
ENV APP_ENV=prod | ||
ENV DATABASE_URL="sqlite:////var/db/app.db" | ||
ENV MAILER_DSN="smtp://localhost:25" | ||
ENV PATH=$PATH:/var/www/bin | ||
|
||
WORKDIR /var/www | ||
|
||
COPY --from=symfony-demo:base /var/www . | ||
COPY --from=symfony-demo:base /var/db /var/db | ||
|
||
# Timezone | ||
RUN ln -snf /usr/share/zoneinfo/Europe/Warsaw /etc/localtime && \ | ||
echo "date.timezone = Europe/Warsaw" >> /usr/local/etc/php/conf.d/datetime.ini; | ||
|
||
RUN a2enmod rewrite | ||
COPY ./docker/apache.conf /etc/apache2/sites-available/000-default.conf | ||
RUN chown -R www-data:www-data /var/www | ||
|
||
CMD ["./bin/docker-init.sh", "apache2-foreground"] |
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,27 @@ | ||
FROM node:latest as assets | ||
WORKDIR /var/www | ||
|
||
COPY ./assets/ ./assets/ | ||
COPY ./package.json webpack.config.js yarn.lock ./ | ||
RUN yarn install && yarn run build | ||
|
||
FROM php:7.4-alpine | ||
|
||
ENV APP_ENV=prod | ||
ENV DATABASE_URL="sqlite:////var/db/app.db" | ||
ENV MAILER_DSN="smtp://localhost:25" | ||
|
||
WORKDIR /var/www | ||
|
||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | ||
COPY . . | ||
COPY --from=assets /var/www/public public | ||
|
||
RUN composer install --prefer-dist --no-progress --no-interaction --ignore-platform-reqs && \ | ||
composer dump-autoload --optimize && \ | ||
php bin/console cache:warmup | ||
|
||
RUN mkdir /var/db && \ | ||
./bin/console doctrine:schema:create && \ | ||
./bin/console doctrine:schema:update --force && \ | ||
yes | APP_ENV=dev ./bin/console doctrine:fixtures:load |
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
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
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,10 @@ | ||
<VirtualHost *:80> | ||
ServerAdmin webmaster@localhost | ||
DocumentRoot /var/www/public | ||
|
||
<Directory /var/www> | ||
Options Indexes FollowSymLinks | ||
AllowOverride All | ||
Require all granted | ||
</Directory> | ||
</VirtualHost> |
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,8 @@ | ||
[www] | ||
listen = 0.0.0.0:9000 | ||
|
||
pm = dynamic | ||
pm.max_children = 32 | ||
pm.start_servers = 8 | ||
pm.min_spare_servers = 4 | ||
pm.max_spare_servers = 8 |
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,27 @@ | ||
server { | ||
listen 8080; | ||
root /var/www/public; | ||
|
||
location / { | ||
try_files $uri /index.php$is_args$args; | ||
} | ||
|
||
location ~ ^/.+\.php(/|$) { | ||
fastcgi_buffer_size 256k; | ||
fastcgi_buffers 64 256k; | ||
fastcgi_pass php-upstream; | ||
fastcgi_split_path_info ^(.+\.php)(/.*)$; | ||
include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | ||
fastcgi_param DOCUMENT_ROOT $realpath_root; | ||
internal; | ||
} | ||
|
||
location ~ \.php$ { | ||
return 404; | ||
} | ||
|
||
error_log /var/log/nginx/error.log; | ||
access_log /var/log/nginx/access.log; | ||
} | ||
|
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 @@ | ||
upstream php-upstream { server fpm:9000; } |
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 |
---|---|---|
@@ -1,25 +1,23 @@ | ||
FROM php:7.4-fpm-alpine | ||
|
||
ENV APP_ENV=prod | ||
ENV DATABASE_URL="sqlite:////var/db/app.db" | ||
ENV PATH=$PATH:/usr/src/app/bin | ||
|
||
RUN apk add --no-cache autoconf openssl-dev g++ make pcre-dev icu-dev zlib-dev libzip-dev git && \ | ||
docker-php-ext-install bcmath intl opcache zip sockets && \ | ||
apk del --purge autoconf g++ make; | ||
|
||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | ||
COPY . . | ||
ENV APP_ENV=prod | ||
ENV DATABASE_URL="sqlite:////var/db/app.db" | ||
ENV MAILER_DSN="smtp://localhost:25" | ||
ENV PATH=$PATH:/var/www/bin | ||
|
||
WORKDIR /var/www | ||
|
||
RUN composer install --no-dev --no-scripts --no-plugins --prefer-dist --no-progress --no-interaction && \ | ||
composer dump-autoload --optimize && \ | ||
composer check-platform-reqs && \ | ||
php bin/console cache:warmup | ||
COPY --from=symfony-demo:base /var/www . | ||
COPY --from=symfony-demo:base /var/db /var/db | ||
|
||
# Timezone | ||
RUN ln -snf /usr/share/zoneinfo/Europe/Warsaw /etc/localtime && \ | ||
echo "date.timezone = Europe/Warsaw" >> /usr/local/etc/php/conf.d/datetime.ini; | ||
|
||
WORKDIR /var/www | ||
ADD ./docker/php-fpm.conf /usr/local/etc/php-fpm.d/symfony.conf | ||
|
||
CMD ["./bin/docker-init.sh", "php-fpm"] |
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,43 @@ | ||
import time | ||
from locust import HttpUser, task, between | ||
from random import randint, choice, seed | ||
|
||
seed(3721) | ||
|
||
class BlogUser(HttpUser): | ||
wait_time = between(1, 2.5) | ||
|
||
def on_start(self): | ||
self.max_pages = 3 | ||
self.tags = [ tag['name'] for tag in self.client.get("/en/api/tags").json() ] | ||
self.queries = ["Lorem ipsum", "vitae velit", "Ubi est", "dolor"] | ||
|
||
@task(5) | ||
def browse_tag(self): | ||
tag = choice(self.tags) | ||
self.client.get(f"/en/blog?tag={tag}") | ||
|
||
posts = self.client.get(f"/en/api/posts?tag={tag}").json() | ||
self.browse_posts(posts, 3) | ||
|
||
@task(10) | ||
def browse_task(self): | ||
page = randint(1, self.max_pages) | ||
|
||
self.client.get(f"/en/blog/page/{page}") | ||
posts = self.client.get(f"/en/api/posts?page={page}").json() | ||
self.browse_posts(posts, 4) | ||
|
||
@task(2) | ||
def search_task(self): | ||
query = choice(self.queries) | ||
posts = self.client.get(f"/en/api/search?q={query}").json() | ||
self.browse_posts(posts, 2) | ||
|
||
def browse_posts(self, posts, count): | ||
if len(posts) == 0: | ||
return | ||
|
||
for _ in range(count): | ||
post = choice(posts) | ||
self.client.get(post['url']) |
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
Oops, something went wrong.