From efddc102d1bf3850eba91789a0d6d704c45d643b Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Thu, 22 Oct 2020 17:08:00 +0200 Subject: [PATCH] Use more configs from env, improved docker setup --- .dockerignore | 18 ++++++++++++--- .gitignore | 2 ++ config/config.default.php | 41 ++++++++++++++++++----------------- docker/Dockerfile | 3 +-- docker/deployment.env | 24 +------------------- docker/dev/deployment.env | 1 + docker/dev/docker-compose.yml | 1 + docker/docker-compose.yml | 2 -- 8 files changed, 42 insertions(+), 50 deletions(-) create mode 100644 docker/dev/deployment.env diff --git a/.dockerignore b/.dockerignore index 34bc37c1..542706c3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,16 @@ -**/docker-compose.yml -**/Dockerfile -docker/deployment.env +# Docker config +docker/ +!docker/nginx/entrypoint.sh +!docker/nginx/nginx.conf + +# Configuration +config/config.php + +# Files .dockerignore +*.git* +.editorconfig +deployment.tpl.yaml +storage/cache/ +!storage/cache/.gitignore +!storage/cache/views/.gitignore diff --git a/.gitignore b/.gitignore index 6089cc32..b1c2cd60 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,9 @@ _vimrc_local.vim # Docker .env files /docker/.env +/docker/deployment.env /docker/dev/.env +/docker/dev/deployment.env # Project files /config/config.php diff --git a/config/config.default.php b/config/config.default.php index 1110fca8..048e737e 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -94,20 +94,20 @@ return [ 'registration_enabled' => (bool)env('REGISTRATION_ENABLED', true), // Only arrived angels can sign up for shifts - 'signup_requires_arrival' => false, + 'signup_requires_arrival' => (bool)env('SIGNUP_REQUIRES_ARRIVAL', false), // Whether newly-registered user should automatically be marked as arrived 'autoarrive' => (bool)env('ANGEL_AUTOARRIVE', false), // Only allow shift signup this number of hours in advance // Setting this to 0 disables the feature - 'signup_advance_hours' => 0, + 'signup_advance_hours' => env('SIGNUP_ADVANCE_HOURS', 0), // Allow signup this many minutes after the start of the shift - 'signup_post_minutes' => 0, + 'signup_post_minutes' => env('SIGNUP_POST_MINUTES', 0), // Number of hours that an angel has to sign out own shifts - 'last_unsubscribe' => 3, + 'last_unsubscribe' => env('LAST_UNSUBSCRIBE', 3), // Define the algorithm to use for `password_verify()` // If the user uses an old algorithm the password will be converted to the new format @@ -118,41 +118,41 @@ return [ 'min_password_length' => env('PASSWORD_MINIMUM_LENGTH', 8), // Whether the DECT field should be enabled - 'enable_dect' => (bool)env('REGISTRATION_ENABLE_DECT', true), + 'enable_dect' => (bool)env('ENABLE_DECT', true), // Enables prename and lastname - 'enable_user_name' => (bool)env('REGISTRATION_ENABLE_USERNAME', false), + 'enable_user_name' => (bool)env('ENABLE_USER_NAME', false), // Enable displaying the pronoun fields - 'enable_pronoun' => (bool)env('REGISTRATION_ENABLE_DECT', false), + 'enable_pronoun' => (bool)env('ENABLE_PRONOUN', false), // Enables the planned arrival/leave date - 'enable_planned_arrival' => (bool)env('REGISTRATION_ENABLE_PLANNED_ARRIVAL', true), + 'enable_planned_arrival' => (bool)env('ENABLE_PLANNED_ARRIVAL', true), // Enables the T-Shirt configuration on signup and profile - 'enable_tshirt_size' => (bool)env('REGISTRATION_ENABLE_TSHIRT', true), + 'enable_tshirt_size' => (bool)env('ENABLE_TSHIRT_SIZE', true), // Number of shifts to freeload until angel is locked for shift signup. - 'max_freeloadable_shifts' => 2, + 'max_freeloadable_shifts' => env('MAX_FREELOADABLE_SHIFTS', 2), // Local timezone 'timezone' => env('TIMEZONE', ini_get('date.timezone') ?: 'Europe/Berlin'), // Multiply 'night shifts' and freeloaded shifts (start or end between 2 and 6 exclusive) by 2 'night_shifts' => [ - 'enabled' => true, // Disable to weigh every shift the same - 'start' => 2, - 'end' => 6, - 'multiplier' => 2, + 'enabled' => (bool)env('NIGHT_SHIFTS', true), // Disable to weigh every shift the same + 'start' => env('NIGHT_SHIFTS_START', 2), + 'end' => env('NIGHT_SHIFTS_END', 6), + 'multiplier' => env('NIGHT_SHIFTS_MULTIPLIER', 2), ], // Voucher calculation 'voucher_settings' => [ - 'initial_vouchers' => 0, - 'shifts_per_voucher' => 0, - 'hours_per_voucher' => 2, + 'initial_vouchers' => env('INITIAL_VOUCHERS', 0), + 'shifts_per_voucher' => env('SHIFTS_PER_VOUCHER', 0), + 'hours_per_voucher' => env('HOURS_PER_VOUCHER', 2), // 'Y-m-d' formatted - 'voucher_start' => null, + 'voucher_start' => env('VOUCHER_START', null) ?: null, ], // Available locales in /resources/lang/ @@ -187,7 +187,8 @@ return [ // Shifts overview // Set max number of hours that can be shown at once - 'filter_max_duration' => 0, + // 0 means no limit + 'filter_max_duration' => env('FILTER_MAX_DURATION', 0), // Session config 'session' => [ @@ -195,7 +196,7 @@ return [ 'driver' => env('SESSION_DRIVER', 'pdo'), // Cookie name - 'name' => 'session', + 'name' => env('SESSION_NAME', 'session'), ], // IP addresses of reverse proxies that are trusted, can be an array or a comma separated list diff --git a/docker/Dockerfile b/docker/Dockerfile index 3f057cd2..f656b3a3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -25,8 +25,7 @@ COPY --from=translation /data/ /app/resources/lang COPY --from=composer /app/vendor/ /app/vendor COPY --from=composer /app/composer.lock /app/ -RUN find /app/storage/ -type f -not -name .gitignore -exec rm {} \; -RUN rm -f /app/config/config.php +RUN find /app/storage/ -type f -not -name VERSION -exec rm {} \; # Build the PHP container FROM php:7-fpm-alpine diff --git a/docker/deployment.env b/docker/deployment.env index 4d933ca9..590fe3c5 100644 --- a/docker/deployment.env +++ b/docker/deployment.env @@ -1,23 +1 @@ -# MAINTENANCE=false -# APP_NAME="Engelsystem" -# ENVIRONMENT= 'production' -# APP_URL=null -# FAQ_URL='https://events.ccc.de/congress/2013/wiki/Static:Volunteers' -# MAIL_DRIVER='mail' -# MAIL_FROM_ADDRESS='noreply@engelsystem.de' -# MAIL_FROM_NAME=Engelsystem -# MAIL_HOST='localhost' -# MAIL_PORT=587 -# THEME=1 -# HOME_SITE='news' -# DISPLAY_NEWS=10 -# REGISTRATION_ENABLED=true -# PASSWORD_MINIMUM_LENGTH=8 -# REGISTRATION_ENABLE_DECT=true -# REGISTRATION_ENABLE_USERNAME=false -# REGISTRATION_ENABLE_DECT=false -# REGISTRATION_ENABLE_PLANNED_ARRIVAL=true -# REGISTRATION_ENABLE_TSHIRT=true -# TIMEZONE='Europe/Berlin' -# DEFAULT_LOCALE='en_US' -# ADD_HEADERS=true +# Additional env config can be added here diff --git a/docker/dev/deployment.env b/docker/dev/deployment.env new file mode 100644 index 00000000..590fe3c5 --- /dev/null +++ b/docker/dev/deployment.env @@ -0,0 +1 @@ +# Additional env config can be added here diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml index 4a2ab24e..af4e00ef 100644 --- a/docker/dev/docker-compose.yml +++ b/docker/dev/docker-compose.yml @@ -33,6 +33,7 @@ services: ENVIRONMENT: development MAIL_DRIVER: log APP_NAME: Engelsystem DEV + env_file: deployment.env networks: - database - fpm diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 4a7894bb..733159ad 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -23,8 +23,6 @@ services: MYSQL_USER: engelsystem MYSQL_PASSWORD: engelsystem MYSQL_DATABASE: engelsystem - # some optional env vars and their defaults can be seen in the env file - # for exact information have a look at config/config.default.php env_file: deployment.env networks: - database