Compare commits

...

4 Commits

6 changed files with 146 additions and 124 deletions

View File

@ -1,7 +1,5 @@
FROM php:8.2-apache FROM php:8.2-apache
WORKDIR /var/www/html
RUN apt update && \ RUN apt update && \
apt upgrade -y && \ apt upgrade -y && \
apt install -y \ apt install -y \
@ -37,16 +35,20 @@ RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" &&
RUN curl -sS https://get.symfony.com/cli/installer | bash && \ RUN curl -sS https://get.symfony.com/cli/installer | bash && \
mv /root/.symfony5/bin/symfony /usr/local/bin/symfony mv /root/.symfony5/bin/symfony /usr/local/bin/symfony
COPY 000-default.conf /etc/apache2/sites-available/
COPY composer.lock composer.json /var/www/html/
RUN composer install --no-scripts --no-dev --optimize-autoloader
COPY . /var/www/html/ COPY . /var/www/html/
RUN rm /var/www/html/.env*
RUN cp /var/www/html/data/data.db /var/www/html/var/ RUN mv 000-default.conf /etc/apache2/sites-available/
RUN rm /var/www/html/.env*
RUN rm -rf /var/www/html/var/*
RUN rm -rf /var/www/html/vendor
RUN rm -rf /var/www/html/tests
RUN rm -rf /var/www/html/translations
RUN COMPOSER_ALLOW_SUPERUSER=1 composer install --no-scripts --no-dev --optimize-autoloader
RUN mv /var/www/html/data/data.db /var/www/html/var/
RUN mkdir /var/www/html/var/cache
RUN mkdir /var/www/html/var/log
RUN chown -R www-data:www-data /var/www/html RUN chown -R www-data:www-data /var/www/html
RUN chmod -R 755 /var/www/html RUN chmod -R 755 /var/www/html

View File

@ -45,7 +45,8 @@
"symfony/web-link": "7.0.*", "symfony/web-link": "7.0.*",
"symfony/yaml": "7.0.*", "symfony/yaml": "7.0.*",
"twig/extra-bundle": "^2.12|^3.0", "twig/extra-bundle": "^2.12|^3.0",
"twig/twig": "^2.12|^3.0" "twig/twig": "^2.12|^3.0",
"symfony/debug-bundle": "7.0.*"
}, },
"config": { "config": {
"allow-plugins": { "allow-plugins": {
@ -101,7 +102,6 @@
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.5",
"symfony/browser-kit": "7.0.*", "symfony/browser-kit": "7.0.*",
"symfony/css-selector": "7.0.*", "symfony/css-selector": "7.0.*",
"symfony/debug-bundle": "7.0.*",
"symfony/maker-bundle": "^1.0", "symfony/maker-bundle": "^1.0",
"symfony/phpunit-bridge": "^7.0", "symfony/phpunit-bridge": "^7.0",
"symfony/stopwatch": "7.0.*", "symfony/stopwatch": "7.0.*",

208
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "361fd73241c9895cbec28ddf0158d96c", "content-hash": "7f57aa7d9b15ae1237c769af447ea233",
"packages": [ "packages": [
{ {
"name": "composer/semver", "name": "composer/semver",
@ -640,16 +640,16 @@
}, },
{ {
"name": "doctrine/event-manager", "name": "doctrine/event-manager",
"version": "2.0.0", "version": "2.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/event-manager.git", "url": "https://github.com/doctrine/event-manager.git",
"reference": "750671534e0241a7c50ea5b43f67e23eb5c96f32" "reference": "b680156fa328f1dfd874fd48c7026c41570b9c6e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/event-manager/zipball/750671534e0241a7c50ea5b43f67e23eb5c96f32", "url": "https://api.github.com/repos/doctrine/event-manager/zipball/b680156fa328f1dfd874fd48c7026c41570b9c6e",
"reference": "750671534e0241a7c50ea5b43f67e23eb5c96f32", "reference": "b680156fa328f1dfd874fd48c7026c41570b9c6e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -659,10 +659,10 @@
"doctrine/common": "<2.9" "doctrine/common": "<2.9"
}, },
"require-dev": { "require-dev": {
"doctrine/coding-standard": "^10", "doctrine/coding-standard": "^12",
"phpstan/phpstan": "^1.8.8", "phpstan/phpstan": "^1.8.8",
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^10.5",
"vimeo/psalm": "^4.28" "vimeo/psalm": "^5.24"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -711,7 +711,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/doctrine/event-manager/issues", "issues": "https://github.com/doctrine/event-manager/issues",
"source": "https://github.com/doctrine/event-manager/tree/2.0.0" "source": "https://github.com/doctrine/event-manager/tree/2.0.1"
}, },
"funding": [ "funding": [
{ {
@ -727,7 +727,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-10-12T20:59:15+00:00" "time": "2024-05-22T20:47:39+00:00"
}, },
{ {
"name": "doctrine/inflector", "name": "doctrine/inflector",
@ -1071,16 +1071,16 @@
}, },
{ {
"name": "doctrine/orm", "name": "doctrine/orm",
"version": "3.1.3", "version": "3.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/orm.git", "url": "https://github.com/doctrine/orm.git",
"reference": "8ca99fdfdca3dc129ed93124e95e7f88b791a354" "reference": "37946d3a21ddf837c0d84f8156ee60a92102e332"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/orm/zipball/8ca99fdfdca3dc129ed93124e95e7f88b791a354", "url": "https://api.github.com/repos/doctrine/orm/zipball/37946d3a21ddf837c0d84f8156ee60a92102e332",
"reference": "8ca99fdfdca3dc129ed93124e95e7f88b791a354", "reference": "37946d3a21ddf837c0d84f8156ee60a92102e332",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1102,12 +1102,12 @@
"require-dev": { "require-dev": {
"doctrine/coding-standard": "^12.0", "doctrine/coding-standard": "^12.0",
"phpbench/phpbench": "^1.0", "phpbench/phpbench": "^1.0",
"phpstan/phpstan": "1.10.59", "phpstan/phpstan": "1.11.1",
"phpunit/phpunit": "^10.4.0", "phpunit/phpunit": "^10.4.0",
"psr/log": "^1 || ^2 || ^3", "psr/log": "^1 || ^2 || ^3",
"squizlabs/php_codesniffer": "3.7.2", "squizlabs/php_codesniffer": "3.7.2",
"symfony/cache": "^5.4 || ^6.2 || ^7.0", "symfony/cache": "^5.4 || ^6.2 || ^7.0",
"vimeo/psalm": "5.22.2" "vimeo/psalm": "5.24.0"
}, },
"suggest": { "suggest": {
"ext-dom": "Provides support for XSD validation for XML mapping files", "ext-dom": "Provides support for XSD validation for XML mapping files",
@ -1153,9 +1153,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/doctrine/orm/issues", "issues": "https://github.com/doctrine/orm/issues",
"source": "https://github.com/doctrine/orm/tree/3.1.3" "source": "https://github.com/doctrine/orm/tree/3.2.0"
}, },
"time": "2024-04-30T07:14:13+00:00" "time": "2024-05-23T14:27:52+00:00"
}, },
{ {
"name": "doctrine/persistence", "name": "doctrine/persistence",
@ -1533,16 +1533,16 @@
}, },
{ {
"name": "phpdocumentor/reflection-docblock", "name": "phpdocumentor/reflection-docblock",
"version": "5.4.0", "version": "5.4.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "298d2febfe79d03fe714eb871d5538da55205b1a" "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/298d2febfe79d03fe714eb871d5538da55205b1a", "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c",
"reference": "298d2febfe79d03fe714eb871d5538da55205b1a", "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1591,9 +1591,9 @@
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"support": { "support": {
"issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
"source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.0" "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.1"
}, },
"time": "2024-04-09T21:13:58+00:00" "time": "2024-05-21T05:55:05+00:00"
}, },
{ {
"name": "phpdocumentor/type-resolver", "name": "phpdocumentor/type-resolver",
@ -2567,6 +2567,80 @@
], ],
"time": "2024-04-18T09:29:19+00:00" "time": "2024-04-18T09:29:19+00:00"
}, },
{
"name": "symfony/debug-bundle",
"version": "v7.0.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug-bundle.git",
"reference": "4b013a2c886cfd0292d90a9a9cebfa29ec7b578c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug-bundle/zipball/4b013a2c886cfd0292d90a9a9cebfa29ec7b578c",
"reference": "4b013a2c886cfd0292d90a9a9cebfa29ec7b578c",
"shasum": ""
},
"require": {
"ext-xml": "*",
"php": ">=8.2",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/twig-bridge": "^6.4|^7.0",
"symfony/var-dumper": "^6.4|^7.0"
},
"conflict": {
"symfony/config": "<6.4",
"symfony/dependency-injection": "<6.4"
},
"require-dev": {
"symfony/config": "^6.4|^7.0",
"symfony/web-profiler-bundle": "^6.4|^7.0"
},
"type": "symfony-bundle",
"autoload": {
"psr-4": {
"Symfony\\Bundle\\DebugBundle\\": ""
},
"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": "Provides a tight integration of the Symfony VarDumper component and the ServerLogCommand from MonologBridge into the Symfony full-stack framework",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/debug-bundle/tree/v7.0.7"
},
"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": "2024-04-18T09:29:19+00:00"
},
{ {
"name": "symfony/dependency-injection", "name": "symfony/dependency-injection",
"version": "v7.0.7", "version": "v7.0.7",
@ -7469,16 +7543,16 @@
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v3.10.2", "version": "v3.10.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/twigphp/Twig.git", "url": "https://github.com/twigphp/Twig.git",
"reference": "7aaed0b8311a557cc8c4047a71fd03153a00e755" "reference": "67f29781ffafa520b0bbfbd8384674b42db04572"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/7aaed0b8311a557cc8c4047a71fd03153a00e755", "url": "https://api.github.com/repos/twigphp/Twig/zipball/67f29781ffafa520b0bbfbd8384674b42db04572",
"reference": "7aaed0b8311a557cc8c4047a71fd03153a00e755", "reference": "67f29781ffafa520b0bbfbd8384674b42db04572",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -7532,7 +7606,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/twigphp/Twig/issues", "issues": "https://github.com/twigphp/Twig/issues",
"source": "https://github.com/twigphp/Twig/tree/v3.10.2" "source": "https://github.com/twigphp/Twig/tree/v3.10.3"
}, },
"funding": [ "funding": [
{ {
@ -7544,7 +7618,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-05-14T06:04:16+00:00" "time": "2024-05-16T10:04:27+00:00"
}, },
{ {
"name": "webmozart/assert", "name": "webmozart/assert",
@ -9426,80 +9500,6 @@
], ],
"time": "2024-04-18T09:29:19+00:00" "time": "2024-04-18T09:29:19+00:00"
}, },
{
"name": "symfony/debug-bundle",
"version": "v7.0.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug-bundle.git",
"reference": "4b013a2c886cfd0292d90a9a9cebfa29ec7b578c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug-bundle/zipball/4b013a2c886cfd0292d90a9a9cebfa29ec7b578c",
"reference": "4b013a2c886cfd0292d90a9a9cebfa29ec7b578c",
"shasum": ""
},
"require": {
"ext-xml": "*",
"php": ">=8.2",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/twig-bridge": "^6.4|^7.0",
"symfony/var-dumper": "^6.4|^7.0"
},
"conflict": {
"symfony/config": "<6.4",
"symfony/dependency-injection": "<6.4"
},
"require-dev": {
"symfony/config": "^6.4|^7.0",
"symfony/web-profiler-bundle": "^6.4|^7.0"
},
"type": "symfony-bundle",
"autoload": {
"psr-4": {
"Symfony\\Bundle\\DebugBundle\\": ""
},
"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": "Provides a tight integration of the Symfony VarDumper component and the ServerLogCommand from MonologBridge into the Symfony full-stack framework",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/debug-bundle/tree/v7.0.7"
},
"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": "2024-04-18T09:29:19+00:00"
},
{ {
"name": "symfony/dom-crawler", "name": "symfony/dom-crawler",
"version": "v7.0.7", "version": "v7.0.7",

View File

@ -1,11 +1,17 @@
#!/bin/bash #!/bin/bash
rm -rf .env*
echo "APP_ENV=prod" > .env
echo "APP_DEBUG=0" >> .env
LENGTH=32 LENGTH=32
SECRET_KEY=$(openssl rand -base64 $LENGTH | tr -d '=' | tr -d '+' | tr -d '/' | tr -d ' ') SECRET_KEY=$(openssl rand -base64 $LENGTH | tr -d '=' | tr -d '+' | tr -d '/' | tr -d ' ')
TRIMMED_KEY=$(cut -c1-32 <<< $SECRET_KEY) TRIMMED_KEY=$(cut -c1-32 <<< $SECRET_KEY)
echo "APP_SECRET=$TRIMMED_KEY" > .env.local echo "APP_SECRET=$TRIMMED_KEY" >> .env
echo "APP_ENV=prod" >> .env.local echo "DATABASE_URL=\"sqlite:///%kernel.project_dir%/var/data.db\"" >> .env
echo "APP_DEBUG=0" >> .env.local echo "MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0" >> .env
echo "DATABASE_URL=\"sqlite:///%kernel.project_dir%/var/data.db\"" >> .env.local
echo "MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0" >> .env.local symfony console doctrine:migrations:migrate --no-interaction
COMPOSER_ALLOW_SUPERUSER=1 composer update

View File

@ -20,6 +20,11 @@ class RegistrationController extends AbstractController
$form = $this->createForm(RegistrationFormType::class, $user); $form = $this->createForm(RegistrationFormType::class, $user);
$form->handleRequest($request); $form->handleRequest($request);
$role = ['ROLE_USER'];
if ($entityManager->getRepository(User::class)->getUserCount() == 0) {
$role = ['ROLE_ADMIN'];
}
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
// encode the plain password // encode the plain password
@ -28,8 +33,8 @@ class RegistrationController extends AbstractController
$user, $user,
$form->get('plainPassword')->getData() $form->get('plainPassword')->getData()
) )
) );
->setRoles(['ROLE_USER']); $user->setRoles($role);
$entityManager->persist($user); $entityManager->persist($user);
$entityManager->flush(); $entityManager->flush();

View File

@ -33,6 +33,15 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();
} }
public function getUserCount(): int
{
return $this->createQueryBuilder('u')
->select('COUNT(u.id)')
->getQuery()
->getSingleScalarResult()
;
}
// /** // /**
// * @return User[] Returns an array of User objects // * @return User[] Returns an array of User objects
// */ // */