Create data directories in docker entry point if they don't exist

This commit is contained in:
Alejandro Celaya
2024-01-03 19:22:33 +01:00
parent 9bdbb59401
commit 554b948775
4 changed files with 22 additions and 5 deletions

View File

@@ -1,6 +1,14 @@
bin/rr bin/rr
config/autoload/*local* config/autoload/*local*
data/* data/infra
data/cache/*
data/log/*
data/locks/*
data/proxies/*
data/migrations_template.txt
data/GeoLite2-City*
data/database.sqlite
data/shlink-tests.db
CHANGELOG.md CHANGELOG.md
CONTRIBUTING.md CONTRIBUTING.md
UPGRADE.md UPGRADE.md

View File

@@ -46,13 +46,16 @@ 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
│ └── [...]
├── docs ├── docs
│ ├── adr │ ├── adr
│ ├── async-api │ ├── async-api
@@ -62,6 +65,7 @@ shlink
│ ├── Core │ ├── Core
│ └── Rest │ └── Rest
├── public ├── public
│ └── [...]
├── composer.json ├── composer.json
└── README.md └── README.md
``` ```
@@ -70,7 +74,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.

View File

@@ -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',
], ],
], ],

View File

@@ -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