Skip to content

Commit

Permalink
Merge pull request #1969 from acelaya-forks/feature/mountable-data-dir
Browse files Browse the repository at this point in the history
Feature/mountable data dir
  • Loading branch information
acelaya authored Jan 4, 2024
2 parents 62b54ce + e7b876f commit f9c9b3d
Show file tree
Hide file tree
Showing 44 changed files with 41 additions and 17 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

## [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
### Added
* *Nothing*
Expand Down
10 changes: 6 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,18 @@ This is a simplified version of the project structure:
```
shlink
├── bin
│ └── cli
│ ├── cli
│ └── [...]
├── config
│ ├── autoload
│ ├── params
│ ├── config.php
│ └── container.php
│ ├── container.php
│ └── [...]
├── data
│ ├── cache
│ ├── locks
│ ├── log
│ ├── migrations
│ └── proxies
├── docs
│ ├── adr
Expand All @@ -67,6 +68,7 @@ shlink
│ ├── Core
│ └── Rest
├── public
│ └── [...]
├── composer.json
└── README.md
```
Expand All @@ -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.
* `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.
* `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.
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"phpunit/phpunit": "^10.4",
"roave/security-advisories": "dev-master",
"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",
"veewee/composer-run-parallel": "^1.3"
},
Expand Down Expand Up @@ -116,7 +116,7 @@
],
"cs": "phpcs -s",
"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": [
"@parallel test:unit test:db",
"@parallel test:api test:cli"
Expand Down
4 changes: 3 additions & 1 deletion config/autoload/router.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
'base_path' => EnvVars::BASE_PATH->loadFromEnv(''),

'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',
],
],
Expand Down
2 changes: 1 addition & 1 deletion config/cli-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
return (static function () {
$migrationsConfig = [
'migrations_paths' => [
'ShlinkMigrations' => 'data/migrations',
'ShlinkMigrations' => 'module/Core/migrations',
],
'table_storage' => [
'table_name' => 'migrations',
Expand Down
8 changes: 4 additions & 4 deletions config/test/bootstrap_api_tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
});

$testHelper->createTestDb(
['bin/cli', 'db:create'],
['bin/cli', 'db:migrate'],
['bin/doctrine', 'orm:schema-tool:drop'],
['bin/doctrine', 'dbal:run-sql'],
createDbCommand: ['bin/cli', 'db:create'],
migrateDbCommand: ['bin/cli', 'db:migrate'],
dropSchemaCommand: ['bin/doctrine', 'orm:schema-tool:drop'],
runSqlCommand: ['bin/doctrine', 'dbal:run-sql'],
);
ApiTest\ApiTestCase::setApiClient($httpClient);
ApiTest\ApiTestCase::setSeedFixturesCallback(fn () => $testHelper->seedFixtures($em, $config['data_fixtures'] ?? []));
8 changes: 4 additions & 4 deletions config/test/bootstrap_db_tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
/** @var ContainerInterface $container */
$container = require __DIR__ . '/../container.php';
$container->get(Helper\TestHelper::class)->createTestDb(
['bin/cli', 'db:create'],
['bin/cli', 'db:migrate'],
['bin/doctrine', 'orm:schema-tool:drop'],
['bin/doctrine', 'dbal:run-sql'],
createDbCommand: ['bin/cli', 'db:create'],
migrateDbCommand: ['bin/cli', 'db:migrate'],
dropSchemaCommand: ['bin/doctrine', 'orm:schema-tool:drop'],
runSqlCommand: ['bin/doctrine', 'dbal:run-sql'],
);
DbTest\DatabaseTestCase::setEntityManager($container->get('em'));
3 changes: 3 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ set -e

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"

# Skip downloading GeoLite2 db file if the license key env var was not defined or skipping was explicitly set
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<!-- Paths to check -->
<file>bin</file>
<file>module</file>
<file>data/migrations</file>
<file>config</file>
<file>docker/config</file>
<file>public/index.php</file>
Expand Down

0 comments on commit f9c9b3d

Please sign in to comment.