mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-28 04:22:04 +03:00
Merge pull request #1969 from acelaya-forks/feature/mountable-data-dir
Feature/mountable data dir
This commit is contained in:
commit
f9c9b3d981
44 changed files with 41 additions and 17 deletions
18
CHANGELOG.md
18
CHANGELOG.md
|
@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
|
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
### Added
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* [#1968](https://github.com/shlinkio/shlink/issues/1968) Move migrations from `data` to `module/Core`.
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#1967](https://github.com/shlinkio/shlink/issues/1967) Allow an empty dir to be mounted in `data` when using the docker image.
|
||||||
|
|
||||||
|
|
||||||
## [3.7.2] - 2023-12-26
|
## [3.7.2] - 2023-12-26
|
||||||
### Added
|
### Added
|
||||||
* *Nothing*
|
* *Nothing*
|
||||||
|
|
|
@ -46,17 +46,18 @@ This is a simplified version of the project structure:
|
||||||
```
|
```
|
||||||
shlink
|
shlink
|
||||||
├── bin
|
├── bin
|
||||||
│ └── cli
|
│ ├── cli
|
||||||
|
│ └── [...]
|
||||||
├── config
|
├── config
|
||||||
│ ├── autoload
|
│ ├── autoload
|
||||||
│ ├── params
|
│ ├── params
|
||||||
│ ├── config.php
|
│ ├── config.php
|
||||||
│ └── container.php
|
│ ├── container.php
|
||||||
|
│ └── [...]
|
||||||
├── data
|
├── data
|
||||||
│ ├── cache
|
│ ├── cache
|
||||||
│ ├── locks
|
│ ├── locks
|
||||||
│ ├── log
|
│ ├── log
|
||||||
│ ├── migrations
|
|
||||||
│ └── proxies
|
│ └── proxies
|
||||||
├── docs
|
├── docs
|
||||||
│ ├── adr
|
│ ├── adr
|
||||||
|
@ -67,6 +68,7 @@ shlink
|
||||||
│ ├── Core
|
│ ├── Core
|
||||||
│ └── Rest
|
│ └── Rest
|
||||||
├── public
|
├── public
|
||||||
|
│ └── [...]
|
||||||
├── composer.json
|
├── composer.json
|
||||||
└── README.md
|
└── README.md
|
||||||
```
|
```
|
||||||
|
@ -75,7 +77,7 @@ The purposes of every folder are:
|
||||||
|
|
||||||
* `bin`: It contains the CLI tools. The `cli` one is the main entry point to run Shlink from the command line.
|
* `bin`: It contains the CLI tools. The `cli` one is the main entry point to run Shlink from the command line.
|
||||||
* `config`: Contains application-wide configurations, which are later merged with the ones provided by every module.
|
* `config`: Contains application-wide configurations, which are later merged with the ones provided by every module.
|
||||||
* `data`: Common runtime-generated git-ignored assets, like logs, caches, etc.
|
* `data`: Common git-ignored assets, like logs, caches, lock files, GeoLite DB files, etc. It's the only location where Shlink may need to write at runtime.
|
||||||
* `docs`: Any project documentation is stored here, like API spec definitions or architectural decision records.
|
* `docs`: Any project documentation is stored here, like API spec definitions or architectural decision records.
|
||||||
* `module`: Contains a sub-folder for every module in the project. Modules contain the source code, tests and configurations for every context in the project.
|
* `module`: Contains a sub-folder for every module in the project. Modules contain the source code, tests and configurations for every context in the project.
|
||||||
* `public`: Few assets (like `favicon.ico` or `robots.txt`) and the web entry point are stored here. This web entry point is not used when serving the app with RoadRunner or openswoole.
|
* `public`: Few assets (like `favicon.ico` or `robots.txt`) and the web entry point are stored here. This web entry point is not used when serving the app with RoadRunner or openswoole.
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
"phpunit/phpunit": "^10.4",
|
"phpunit/phpunit": "^10.4",
|
||||||
"roave/security-advisories": "dev-master",
|
"roave/security-advisories": "dev-master",
|
||||||
"shlinkio/php-coding-standard": "~2.3.0",
|
"shlinkio/php-coding-standard": "~2.3.0",
|
||||||
"shlinkio/shlink-test-utils": "^3.8",
|
"shlinkio/shlink-test-utils": "^3.8.1",
|
||||||
"symfony/var-dumper": "^6.3",
|
"symfony/var-dumper": "^6.3",
|
||||||
"veewee/composer-run-parallel": "^1.3"
|
"veewee/composer-run-parallel": "^1.3"
|
||||||
},
|
},
|
||||||
|
@ -116,7 +116,7 @@
|
||||||
],
|
],
|
||||||
"cs": "phpcs -s",
|
"cs": "phpcs -s",
|
||||||
"cs:fix": "phpcbf",
|
"cs:fix": "phpcbf",
|
||||||
"stan": "APP_ENV=test php vendor/bin/phpstan analyse module/*/src module/*/test* module/*/config config docker/config data/migrations --level=8",
|
"stan": "APP_ENV=test php vendor/bin/phpstan analyse module/*/src module/*/test* module/*/config module/*/migrations config docker/config --level=8",
|
||||||
"test": [
|
"test": [
|
||||||
"@parallel test:unit test:db",
|
"@parallel test:unit test:db",
|
||||||
"@parallel test:api test:cli"
|
"@parallel test:api test:cli"
|
||||||
|
|
|
@ -11,7 +11,9 @@ return [
|
||||||
'base_path' => EnvVars::BASE_PATH->loadFromEnv(''),
|
'base_path' => EnvVars::BASE_PATH->loadFromEnv(''),
|
||||||
|
|
||||||
'fastroute' => [
|
'fastroute' => [
|
||||||
FastRouteRouter::CONFIG_CACHE_ENABLED => true,
|
// Disabling config cache for cli, ensures it's never used for openswoole/RoadRunner, and also that console
|
||||||
|
// commands don't generate a cache file that's then used by php-fpm web executions
|
||||||
|
FastRouteRouter::CONFIG_CACHE_ENABLED => PHP_SAPI !== 'cli',
|
||||||
FastRouteRouter::CONFIG_CACHE_FILE => 'data/cache/fastroute_cached_routes.php',
|
FastRouteRouter::CONFIG_CACHE_FILE => 'data/cache/fastroute_cached_routes.php',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
|
@ -11,7 +11,7 @@ use Doctrine\Migrations\DependencyFactory;
|
||||||
return (static function () {
|
return (static function () {
|
||||||
$migrationsConfig = [
|
$migrationsConfig = [
|
||||||
'migrations_paths' => [
|
'migrations_paths' => [
|
||||||
'ShlinkMigrations' => 'data/migrations',
|
'ShlinkMigrations' => 'module/Core/migrations',
|
||||||
],
|
],
|
||||||
'table_storage' => [
|
'table_storage' => [
|
||||||
'table_name' => 'migrations',
|
'table_name' => 'migrations',
|
||||||
|
|
|
@ -29,10 +29,10 @@ register_shutdown_function(function () use ($httpClient): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
$testHelper->createTestDb(
|
$testHelper->createTestDb(
|
||||||
['bin/cli', 'db:create'],
|
createDbCommand: ['bin/cli', 'db:create'],
|
||||||
['bin/cli', 'db:migrate'],
|
migrateDbCommand: ['bin/cli', 'db:migrate'],
|
||||||
['bin/doctrine', 'orm:schema-tool:drop'],
|
dropSchemaCommand: ['bin/doctrine', 'orm:schema-tool:drop'],
|
||||||
['bin/doctrine', 'dbal:run-sql'],
|
runSqlCommand: ['bin/doctrine', 'dbal:run-sql'],
|
||||||
);
|
);
|
||||||
ApiTest\ApiTestCase::setApiClient($httpClient);
|
ApiTest\ApiTestCase::setApiClient($httpClient);
|
||||||
ApiTest\ApiTestCase::setSeedFixturesCallback(fn () => $testHelper->seedFixtures($em, $config['data_fixtures'] ?? []));
|
ApiTest\ApiTestCase::setSeedFixturesCallback(fn () => $testHelper->seedFixtures($em, $config['data_fixtures'] ?? []));
|
||||||
|
|
|
@ -9,9 +9,9 @@ use Psr\Container\ContainerInterface;
|
||||||
/** @var ContainerInterface $container */
|
/** @var ContainerInterface $container */
|
||||||
$container = require __DIR__ . '/../container.php';
|
$container = require __DIR__ . '/../container.php';
|
||||||
$container->get(Helper\TestHelper::class)->createTestDb(
|
$container->get(Helper\TestHelper::class)->createTestDb(
|
||||||
['bin/cli', 'db:create'],
|
createDbCommand: ['bin/cli', 'db:create'],
|
||||||
['bin/cli', 'db:migrate'],
|
migrateDbCommand: ['bin/cli', 'db:migrate'],
|
||||||
['bin/doctrine', 'orm:schema-tool:drop'],
|
dropSchemaCommand: ['bin/doctrine', 'orm:schema-tool:drop'],
|
||||||
['bin/doctrine', 'dbal:run-sql'],
|
runSqlCommand: ['bin/doctrine', 'dbal:run-sql'],
|
||||||
);
|
);
|
||||||
DbTest\DatabaseTestCase::setEntityManager($container->get('em'));
|
DbTest\DatabaseTestCase::setEntityManager($container->get('em'));
|
||||||
|
|
|
@ -3,6 +3,9 @@ set -e
|
||||||
|
|
||||||
cd /etc/shlink
|
cd /etc/shlink
|
||||||
|
|
||||||
|
# Create data directories if they do not exist. This allows data dir to be mounted as an empty dir if needed
|
||||||
|
mkdir -p data/cache data/locks data/log data/proxies
|
||||||
|
|
||||||
flags="--no-interaction --clear-db-cache"
|
flags="--no-interaction --clear-db-cache"
|
||||||
|
|
||||||
# Skip downloading GeoLite2 db file if the license key env var was not defined or skipping was explicitly set
|
# Skip downloading GeoLite2 db file if the license key env var was not defined or skipping was explicitly set
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
<!-- Paths to check -->
|
<!-- Paths to check -->
|
||||||
<file>bin</file>
|
<file>bin</file>
|
||||||
<file>module</file>
|
<file>module</file>
|
||||||
<file>data/migrations</file>
|
|
||||||
<file>config</file>
|
<file>config</file>
|
||||||
<file>docker/config</file>
|
<file>docker/config</file>
|
||||||
<file>public/index.php</file>
|
<file>public/index.php</file>
|
||||||
|
|
Loading…
Add table
Reference in a new issue