Compare commits

...

4 Commits

Author SHA1 Message Date
Kacper Donat
a07f4add1f #50 - Refactor Dockerfiles for better cacheability 2021-04-11 19:00:06 +02:00
Kacper Donat
b278388153 #50 - Messenger configuration 2021-04-09 21:52:51 +02:00
Kacper Donat
6e9bafd043 #50 - Ability to run update on separate worker process 2021-04-09 18:36:23 +02:00
Kacper Donat
86ccaad923 #50 - Fix spacing issues 2021-04-08 20:53:38 +02:00
26 changed files with 763 additions and 104 deletions

View File

@ -16,3 +16,7 @@ APP_SECRET=494a9d1f8cc383f16075f4d5e54ae1a2
DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db"
# DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7"
###< doctrine/doctrine-bundle ###
###> symfony/messenger ###
APP_EVENT_QUEUE_DSN="doctrine://default"
###< symfony/messenger ###

View File

@ -1,11 +1,8 @@
FROM php:7.4-fpm-alpine
ENV APP_ENV=dev
ENV DATABASE_URL="sqlite:///var/db/app.db"
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
# Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
RUN install-php-extensions bcmath intl opcache zip sockets xdebug-^3.0;

View File

@ -0,0 +1,3 @@
#!/bin/sh
exec "$@"

View File

@ -4,12 +4,13 @@
"type": "project",
"license": "MIT with Commons Clause",
"require": {
"php": "^7.1.3",
"php": "^7.4",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-json": "*",
"baldinof/roadrunner-bundle": "^1.3",
"cerbero/json-objects": "^1.1",
"illuminate/collections": "^8.35",
"jms/serializer-bundle": "^3.5",
"kadet/functional": "dev-master",
"nelmio/api-doc-bundle": "^3.5",
@ -19,15 +20,18 @@
"spiral/roadrunner": "^1.8",
"symfony/asset": "^5.2",
"symfony/console": "^5.2",
"symfony/dotenv": "^5.2",
"symfony/doctrine-messenger": "5.2.*",
"symfony/flex": "^1.1",
"symfony/framework-bundle": "^5.2",
"symfony/messenger": "5.2.*",
"symfony/monolog-bundle": "^3.3",
"symfony/orm-pack": "^1.0",
"symfony/profiler-pack": "^1.0",
"symfony/twig-bundle": "^5.2",
"symfony/yaml": "^5.2",
"illuminate/collections": "^8.35"
"symfony/dotenv": "5.2.*",
"symfony/amqp-messenger": "5.2.*",
"symfony/redis-messenger": "5.2.*"
},
"config": {
"preferred-install": {
@ -36,7 +40,7 @@
"sort-packages": true,
"secure-http": false,
"platform": {
"php": "7.3.12"
"php": "7.4.15"
}
},
"autoload": {
@ -86,5 +90,8 @@
"type": "vcs",
"url": "https://git.kadet.net/kadet/functional-php.git"
}
]
],
"require-dev": {
"symfony/maker-bundle": "^1.30"
}
}

486
api/composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4c087fa5970989805008ea426fdd2221",
"content-hash": "3703fdd98d8c7ed6539721bde9035bba",
"packages": [
{
"name": "baldinof/roadrunner-bundle",
@ -3693,6 +3693,75 @@
},
"time": "2021-01-14T16:04:43+00:00"
},
{
"name": "symfony/amqp-messenger",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/amqp-messenger.git",
"reference": "cf309a35ed08caa77886ee6a352b8491c7681424"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/amqp-messenger/zipball/cf309a35ed08caa77886ee6a352b8491c7681424",
"reference": "cf309a35ed08caa77886ee6a352b8491c7681424",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/messenger": "^5.1"
},
"require-dev": {
"symfony/event-dispatcher": "^4.4|^5.0",
"symfony/process": "^4.4|^5.0",
"symfony/property-access": "^4.4|^5.0",
"symfony/serializer": "^4.4|^5.0"
},
"type": "symfony-bridge",
"autoload": {
"psr-4": {
"Symfony\\Component\\Messenger\\Bridge\\Amqp\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony AMQP extension Messenger Bridge",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/amqp-messenger/tree/v5.2.4"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-01-27T11:19:04+00:00"
},
{
"name": "symfony/asset",
"version": "v5.2.4",
@ -4380,30 +4449,38 @@
"time": "2021-03-10T22:10:15+00:00"
},
{
"name": "symfony/dotenv",
"version": "v5.2.4",
"name": "symfony/doctrine-messenger",
"version": "v5.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/dotenv.git",
"reference": "783f12027c6b40ab0e93d6136d9f642d1d67cd6b"
"url": "https://github.com/symfony/doctrine-messenger.git",
"reference": "10136ef0e31ca9839254bd909ef42421b61bc118"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dotenv/zipball/783f12027c6b40ab0e93d6136d9f642d1d67cd6b",
"reference": "783f12027c6b40ab0e93d6136d9f642d1d67cd6b",
"url": "https://api.github.com/repos/symfony/doctrine-messenger/zipball/10136ef0e31ca9839254bd909ef42421b61bc118",
"reference": "10136ef0e31ca9839254bd909ef42421b61bc118",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1"
"symfony/messenger": "^5.1",
"symfony/service-contracts": "^1.1|^2"
},
"conflict": {
"doctrine/dbal": "<2.10",
"doctrine/persistence": "<1.3"
},
"require-dev": {
"symfony/process": "^4.4|^5.0"
"doctrine/dbal": "^2.10|^3.0",
"doctrine/persistence": "^1.3|^2",
"symfony/property-access": "^4.4|^5.0",
"symfony/serializer": "^4.4|^5.0"
},
"type": "library",
"type": "symfony-bridge",
"autoload": {
"psr-4": {
"Symfony\\Component\\Dotenv\\": ""
"Symfony\\Component\\Messenger\\Bridge\\Doctrine\\": ""
},
"exclude-from-classmap": [
"/Tests/"
@ -4423,15 +4500,10 @@
"homepage": "https://symfony.com/contributors"
}
],
"description": "Registers environment variables from a .env file",
"description": "Symfony Doctrine Messenger Bridge",
"homepage": "https://symfony.com",
"keywords": [
"dotenv",
"env",
"environment"
],
"support": {
"source": "https://github.com/symfony/dotenv/tree/v5.2.4"
"source": "https://github.com/symfony/doctrine-messenger/tree/v5.2.5"
},
"funding": [
{
@ -4447,7 +4519,7 @@
"type": "tidelift"
}
],
"time": "2021-01-27T10:01:46+00:00"
"time": "2021-03-05T12:14:19+00:00"
},
{
"name": "symfony/error-handler",
@ -5286,6 +5358,94 @@
],
"time": "2021-03-29T05:16:58+00:00"
},
{
"name": "symfony/messenger",
"version": "v5.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/messenger.git",
"reference": "bc012fde3b96cfa3adf22f4d8a2e17860dc24a65"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/messenger/zipball/bc012fde3b96cfa3adf22f4d8a2e17860dc24a65",
"reference": "bc012fde3b96cfa3adf22f4d8a2e17860dc24a65",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"psr/log": "~1.0",
"symfony/amqp-messenger": "^5.1",
"symfony/deprecation-contracts": "^2.1",
"symfony/doctrine-messenger": "^5.1",
"symfony/polyfill-php80": "^1.15",
"symfony/redis-messenger": "^5.1"
},
"conflict": {
"symfony/event-dispatcher": "<4.4",
"symfony/framework-bundle": "<4.4",
"symfony/http-kernel": "<4.4"
},
"require-dev": {
"psr/cache": "^1.0|^2.0|^3.0",
"symfony/console": "^4.4|^5.0",
"symfony/dependency-injection": "^4.4|^5.0",
"symfony/event-dispatcher": "^4.4|^5.0",
"symfony/http-kernel": "^4.4|^5.0",
"symfony/process": "^4.4|^5.0",
"symfony/property-access": "^4.4|^5.0",
"symfony/serializer": "^4.4|^5.0",
"symfony/service-contracts": "^1.1|^2",
"symfony/stopwatch": "^4.4|^5.0",
"symfony/validator": "^4.4|^5.0"
},
"suggest": {
"enqueue/messenger-adapter": "For using the php-enqueue library as a transport."
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Messenger\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Samuel Roze",
"email": "samuel.roze@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Helps applications send and receive messages to/from other applications or via message queues",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/messenger/tree/v5.2.5"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-03-06T07:59:01+00:00"
},
{
"name": "symfony/monolog-bridge",
"version": "v5.2.5",
@ -6194,6 +6354,73 @@
],
"time": "2021-02-17T10:35:25+00:00"
},
{
"name": "symfony/redis-messenger",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/redis-messenger.git",
"reference": "7e68914bf35cda948ee4d9081b8eaed9fd783fe5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/redis-messenger/zipball/7e68914bf35cda948ee4d9081b8eaed9fd783fe5",
"reference": "7e68914bf35cda948ee4d9081b8eaed9fd783fe5",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/messenger": "^5.1"
},
"require-dev": {
"symfony/property-access": "^4.4|^5.0",
"symfony/serializer": "^4.4|^5.0"
},
"type": "symfony-bridge",
"autoload": {
"psr-4": {
"Symfony\\Component\\Messenger\\Bridge\\Redis\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Redis extension Messenger Bridge",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/redis-messenger/tree/v5.2.4"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-01-27T11:24:50+00:00"
},
{
"name": "symfony/routing",
"version": "v5.2.6",
@ -7525,7 +7752,222 @@
"time": "2020-11-29T21:40:13+00:00"
}
],
"packages-dev": [],
"packages-dev": [
{
"name": "nikic/php-parser",
"version": "v4.10.4",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "c6d052fc58cb876152f89f532b95a8d7907e7f0e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c6d052fc58cb876152f89f532b95a8d7907e7f0e",
"reference": "c6d052fc58cb876152f89f532b95a8d7907e7f0e",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=7.0"
},
"require-dev": {
"ircmaxell/php-yacc": "^0.0.7",
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
},
"bin": [
"bin/php-parse"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.9-dev"
}
},
"autoload": {
"psr-4": {
"PhpParser\\": "lib/PhpParser"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Nikita Popov"
}
],
"description": "A PHP parser written in PHP",
"keywords": [
"parser",
"php"
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.10.4"
},
"time": "2020-12-20T10:01:03+00:00"
},
{
"name": "symfony/dotenv",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/dotenv.git",
"reference": "783f12027c6b40ab0e93d6136d9f642d1d67cd6b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dotenv/zipball/783f12027c6b40ab0e93d6136d9f642d1d67cd6b",
"reference": "783f12027c6b40ab0e93d6136d9f642d1d67cd6b",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1"
},
"require-dev": {
"symfony/process": "^4.4|^5.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Dotenv\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Registers environment variables from a .env file",
"homepage": "https://symfony.com",
"keywords": [
"dotenv",
"env",
"environment"
],
"support": {
"source": "https://github.com/symfony/dotenv/tree/v5.2.4"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-01-27T10:01:46+00:00"
},
{
"name": "symfony/maker-bundle",
"version": "v1.30.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/maker-bundle.git",
"reference": "a395a85aa4ded6c1fa3da118d60329b64b6c2acd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/maker-bundle/zipball/a395a85aa4ded6c1fa3da118d60329b64b6c2acd",
"reference": "a395a85aa4ded6c1fa3da118d60329b64b6c2acd",
"shasum": ""
},
"require": {
"doctrine/inflector": "^1.2|^2.0",
"nikic/php-parser": "^4.0",
"php": ">=7.1.3",
"symfony/config": "^4.0|^5.0",
"symfony/console": "^4.0|^5.0",
"symfony/dependency-injection": "^4.0|^5.0",
"symfony/deprecation-contracts": "^2.2",
"symfony/filesystem": "^4.0|^5.0",
"symfony/finder": "^4.0|^5.0",
"symfony/framework-bundle": "^4.0|^5.0",
"symfony/http-kernel": "^4.0|^5.0"
},
"require-dev": {
"composer/semver": "^3.0@dev",
"doctrine/doctrine-bundle": "^1.8|^2.0",
"doctrine/orm": "^2.3",
"friendsofphp/php-cs-fixer": "^2.8",
"friendsoftwig/twigcs": "^4.1.0|^5.0.0",
"symfony/http-client": "^4.3|^5.0",
"symfony/phpunit-bridge": "^4.3|^5.0",
"symfony/process": "^4.0|^5.0",
"symfony/security-core": "^4.0|^5.0",
"symfony/yaml": "^4.0|^5.0"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-main": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Bundle\\MakerBundle\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.",
"homepage": "https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html",
"keywords": [
"code generator",
"generator",
"scaffold",
"scaffolding"
],
"support": {
"issues": "https://github.com/symfony/maker-bundle/issues",
"source": "https://github.com/symfony/maker-bundle/tree/v1.30.2"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-03-23T13:53:38+00:00"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
@ -7534,14 +7976,14 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": "^7.1.3",
"php": "^7.4",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-json": "*"
},
"platform-dev": [],
"platform-overrides": {
"php": "7.3.12"
"php": "7.4.15"
},
"plugin-api-version": "2.0.0"
}

View File

@ -11,4 +11,5 @@ return [
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Baldinof\RoadRunnerBundle\BaldinofRoadRunnerBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
];

View File

@ -0,0 +1,11 @@
parameters:
env(APP_EVENT_QUEUE): "doctrine://default"
framework:
messenger:
transports:
main: '%env(resolve:APP_EVENT_QUEUE)%'
sync: 'sync://'
routing:
'App\Message\UpdateDataMessage': main

View File

@ -1,25 +0,0 @@
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 . .
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
# 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
CMD ["./bin/docker-init.sh", "php-fpm"]

View File

@ -1,25 +0,0 @@
FROM php:7.4-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
WORKDIR /usr/src/app
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY . .
RUN composer install --no-dev --no-scripts --no-plugins --prefer-dist --no-progress --no-interaction
RUN ./vendor/bin/rr get-binary --location /usr/local/bin
RUN composer dump-autoload --optimize && \
composer check-platform-reqs && \
php bin/console cache:warmup
EXPOSE 8080
CMD ["./bin/docker-init.sh", "rr", "serve"]

View File

@ -2,29 +2,47 @@
namespace App\Command;
use App\Message\UpdateDataMessage;
use App\Service\DataUpdater;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Messenger\MessageBusInterface;
class UpdateCommand extends Command
{
/** @var DataUpdater */
private $updater;
/** @var MessageBusInterface */
private $bus;
/**
* UpdateCommand constructor.
*
* @param $updater
*/
public function __construct(DataUpdater $updater)
public function __construct(DataUpdater $updater, MessageBusInterface $bus)
{
parent::__construct('app:update');
$this->updater = $updater;
$this->bus = $bus;
}
protected function configure()
{
$this->addOption(
'async', 'a',
InputOption::VALUE_NONE,
'Run in worker process via message queue.'
);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->updater->update($output);
if ($input->getOption('async')) {
$this->bus->dispatch(new UpdateDataMessage());
$output->writeln("Update request sent to message queue.");
} else {
$this->updater->update($output);
}
return Command::SUCCESS;
}
}
}

View File

@ -0,0 +1,7 @@
<?php
namespace App\Message;
final class UpdateDataMessage
{
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\MessageHandler;
use App\Message\UpdateDataMessage;
use App\Output\LoggerOutput;
use App\Service\DataUpdater;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
final class UpdateDataMessageHandler implements MessageHandlerInterface, LoggerAwareInterface
{
use LoggerAwareTrait;
/** @var DataUpdater */
private $updater;
public function __construct(DataUpdater $updater)
{
$this->updater = $updater;
}
public function __invoke(UpdateDataMessage $message)
{
try {
$this->updater->update(new LoggerOutput($this->logger));
} catch (\Exception $exception) {
$this->logger->critical($exception->getMessage(), [
'backtrace' => $exception->getTraceAsString()
]);
}
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Output;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Output\Output;
class LoggerOutput extends Output
{
/** @var LoggerInterface */
private $logger;
public function __construct(
LoggerInterface $logger,
?int $verbosity = self::VERBOSITY_NORMAL,
bool $decorated = false,
OutputFormatterInterface $formatter = null
) {
parent::__construct($verbosity, $decorated, $formatter);
$this->logger = $logger;
}
protected function doWrite(string $message, bool $newline)
{
$this->logger->info($message);
}
}

View File

@ -5,6 +5,7 @@ namespace App\Service;
use App\Event\DataUpdateEvent;
use Doctrine\DBAL\Schema\Table;
use Doctrine\ORM\EntityManagerInterface;
use Kadet\Functional as f;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
@ -18,11 +19,6 @@ class DataUpdater
/** @var EntityManagerInterface */
private $em;
/**
* DataUpdater constructor.
*
* @param EventDispatcherInterface $dispatcher
*/
public function __construct(EventDispatcherInterface $dispatcher, EntityManagerInterface $em)
{
$this->dispatcher = $dispatcher;
@ -41,11 +37,13 @@ class DataUpdater
copy($path, $backup);
try {
collect($schema->listTables())->reject(function (Table $schema) {
return $schema->getName() === 'migration_versions';
})->each([$schema, 'dropAndCreateTable']);
collect($schema->listTables())
->reject(f\ref([$this, 'shouldTableBePreserved']))
->each(f\ref([$schema, 'dropAndCreateTable']))
;
$this->dispatcher->dispatch(new DataUpdateEvent($output), DataUpdateEvent::NAME);
unlink($backup);
} catch (\Throwable $exception) {
$connection->close();
@ -56,4 +54,9 @@ class DataUpdater
throw $exception;
}
}
private function shouldTableBePreserved(Table $schema)
{
return in_array($schema->getName(), ['migration_versions', 'messenger_messages']);
}
}

View File

@ -197,6 +197,9 @@
"nesbot/carbon": {
"version": "1.33.0"
},
"nikic/php-parser": {
"version": "v4.10.4"
},
"ocramius/package-versions": {
"version": "1.3.0"
},
@ -266,6 +269,9 @@
"spiral/roadrunner": {
"version": "v1.8.4"
},
"symfony/amqp-messenger": {
"version": "v5.2.4"
},
"symfony/asset": {
"version": "v4.1.4"
},
@ -296,6 +302,9 @@
"symfony/doctrine-bridge": {
"version": "v4.1.4"
},
"symfony/doctrine-messenger": {
"version": "v5.2.5"
},
"symfony/dotenv": {
"version": "v4.1.3"
},
@ -356,6 +365,27 @@
"symfony/http-kernel": {
"version": "v4.1.3"
},
"symfony/maker-bundle": {
"version": "1.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.0",
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
}
},
"symfony/messenger": {
"version": "4.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "4.3",
"ref": "e9a414b113ceadbf4e52abe37bf8f1b443f06ccb"
},
"files": [
"config/packages/messenger.yaml"
]
},
"symfony/monolog-bridge": {
"version": "v4.1.4"
},
@ -401,6 +431,9 @@
"symfony/psr-http-message-bridge": {
"version": "v2.0.2"
},
"symfony/redis-messenger": {
"version": "v5.2.4"
},
"symfony/routing": {
"version": "4.0",
"recipe": {

View File

@ -13,12 +13,12 @@ services:
api:
build:
context: ./api
dockerfile: dev.Dockerfile
dockerfile: Dockerfile
env_file:
- ./docker/php/.env
- ./docker/api/.env
volumes:
- ./api:/var/www:cached
- ./docker/php/log.conf:/usr/local/etc/php-fpm.d/zz-log.conf
- ./docker/api/log.conf:/usr/local/etc/php-fpm.d/zz-log.conf
frontend:
image: node:15.2.1

29
docker/api/fpm.Dockerfile Normal file
View File

@ -0,0 +1,29 @@
FROM php:7.4-fpm-alpine
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
RUN install-php-extensions bcmath intl opcache zip sockets;
COPY composer.json composer.lock ./
RUN apk add git && \
composer install --no-dev --no-scripts --no-plugins --prefer-dist --no-progress --no-interaction && \
composer dump-autoload --optimize && \
composer check-platform-reqs && \
composer clear-cache && \
apk del --purge git
COPY . .
ENV APP_ENV=prod
ENV DATABASE_URL="sqlite:////var/db/app.db"
ENV PATH=$PATH:/var/www/bin
RUN composer run-script post-install-cmd
CMD ["./bin/docker-init.sh", "php-fpm"]

37
docker/api/rr.Dockerfile Normal file
View File

@ -0,0 +1,37 @@
FROM php:7.4-alpinpe
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
RUN install-php-extensions bcmath intl opcache zip sockets;
COPY composer.json composer.lock ./
RUN apk add git && \
composer install --no-dev --no-scripts --no-plugins --prefer-dist --no-progress --no-interaction && \
composer dump-autoload --optimize && \
composer check-platform-reqs && \
composer clear-cache && \
apk del --purge git
# this touch is needed because get-binary calls the autoloader
RUN mkdir -p ./src/Functions && \
touch src/Functions/index.php && \
./vendor/bin/rr get-binary --location /usr/local/bin
COPY . .
ENV APP_ENV=prod
ENV DATABASE_URL="sqlite:////var/db/app.db"
ENV PATH=$PATH:/var/www/bin
RUN composer run-script post-install-cmd
RUN mkdir /var/db
EXPOSE 8080
CMD ["./bin/docker-init.sh", "rr", "serve"]

45
docker/worker/Dockerfile Normal file
View File

@ -0,0 +1,45 @@
FROM php:7.4-cli-alpine
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
RUN apk add supervisor && \
{ \
echo '[supervisord]'; \
echo 'nodaemon=true'; \
echo ; \
echo '[program:messenger-consumer]'; \
echo 'command=php /var/www/bin/console messenger:consume main -vv --time-limit=86400 --limit=10'; \
echo 'startsecs=0'; \
echo 'start=true'; \
echo 'autorestart=true'; \
echo 'stdout_logfile=/dev/stdout'; \
echo 'stderr_logfile=/dev/stderr'; \
echo 'stdout_logfile_maxbytes=0'; \
echo 'stderr_logfile_maxbytes=0'; \
} | tee /etc/supervisord.conf;
WORKDIR /var/www
RUN install-php-extensions bcmath intl opcache zip sockets;
COPY composer.json composer.lock ./
RUN apk add git && \
composer install --no-dev --no-scripts --no-plugins --prefer-dist --no-progress --no-interaction && \
composer dump-autoload --optimize && \
composer check-platform-reqs && \
composer clear-cache && \
apk del --purge git
COPY . .
ENV APP_ENV=prod
ENV DATABASE_URL="sqlite:////var/db/app.db"
ENV PATH=$PATH:/var/www/bin
RUN composer run-script post-install-cmd
CMD ["supervisord", "-c", "/etc/supervisord.conf"]

View File

@ -0,0 +1,2 @@
[supervisord]
nodaemon=true

View File

@ -23,6 +23,8 @@ RUN yarn install --production
FROM node:15.2.1-slim
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
WORKDIR /app
COPY --from=build /app/build/ build

View File

@ -100,6 +100,10 @@ export default class UiDialog extends Vue {
const isInWrapper = this.$parent.$options.name == 'portalTarget';
if (typeof this.reference === 'string') {
if (this.reference[0] === '#') {
return document.getElementById(this.reference.substr(1));
}
if (this.refs) {
return this.refs[this.reference];
}

View File

@ -7,7 +7,7 @@
<ui-icon icon="messages" fixed-width class="mr-2"></ui-icon>
Komunikaty <span class="ml-2 badge badge-pill badge-dark">{{ messages.count }}</span>
</h2>
<button class="btn btn-action flex-space-left" ref="settings-messages"
<button class="btn btn-action flex-space-left" ref="settings-messages" id="settings-messages"
@click="visibility.messages = !visibility.messages">
<tooltip>ustawienia</tooltip>
<ui-icon icon="settings" fixed-width></ui-icon>
@ -25,7 +25,7 @@
</button>
<portal to="popups">
<ui-dialog reference="settings-messages" v-if="visibility.messages" arrow placement="left-start"
<ui-dialog reference="#settings-messages" v-if="visibility.messages" arrow placement="left-start"
@leave="visibility.messages = false">
<settings-messages></settings-messages>
</ui-dialog>
@ -42,7 +42,7 @@
<span class="text">Odjazdy</span>
</h2>
<button class="btn btn-action flex-space-left" ref="settings-departures"
<button class="btn btn-action flex-space-left" ref="settings-departures" id="settings-departures"
@click="visibility.departures = !visibility.departures">
<tooltip>ustawienia</tooltip>
<ui-icon icon="settings" fixed-width></ui-icon>
@ -52,7 +52,7 @@
<ui-icon icon="refresh" :spin="departures.state === 'fetching'" fixed-width></ui-icon>
</button>
<portal to="popups">
<ui-dialog reference="settings-departures" v-if="visibility.departures"
<ui-dialog reference="#settings-departures" v-if="visibility.departures"
@leave="visibility.departures = false" arrow placement="left-start">
<settings-departures></settings-departures>
</ui-dialog>

View File

@ -1,6 +1,6 @@
<div>
<div class="d-flex">
<div class="d-flex position-relative" style="min-width: 0">
<div class="d-flex position-relative" style="min-width: 0; flex: 1 1 auto;">
<slot name="primary-action" />
<div class="overflow-hidden align-self-center">
<stop :stop="stop" />