Skip to content

Commit

Permalink
Adds support for all config parameters as env variables.
Browse files Browse the repository at this point in the history
Fixes #12
  • Loading branch information
mhubig committed Apr 12, 2020
1 parent 120e723 commit 10fd81a
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 54 deletions.
50 changes: 44 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,50 @@ services:
partkeepr:
image: mhubig/partkeepr:latest
environment:
- PARTKEEPR_DATABASE_HOST=database
- PARTKEEPR_DATABASE_NAME=partkeepr
- PARTKEEPR_DATABASE_PORT=3306
- PARTKEEPR_DATABASE_USER=partkeepr
- PARTKEEPR_DATABASE_PASS=partkeepr
- PARTKEEPR_OKTOPART_APIKEY
- PARTKEEPR_DATABASE_HOST
- PARTKEEPR_DATABASE_NAME
- PARTKEEPR_DATABASE_PORT
- PARTKEEPR_DATABASE_USER
- PARTKEEPR_DATABASE_PASS
- PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTCANONICALFORM
- PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTDOMAINNAME
- PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTDOMAINNAMESHORT
- PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTFILTERFORMAT
- PARTKEEPR_FR3D_LDAP_DRIVER_BASEDN
- PARTKEEPR_FR3D_LDAP_DRIVER_BINDREQUIRESDN
- PARTKEEPR_FR3D_LDAP_DRIVER_HOST
- PARTKEEPR_FR3D_LDAP_DRIVER_OPTREFERRALS
- PARTKEEPR_FR3D_LDAP_DRIVER_PASSWORD
- PARTKEEPR_FR3D_LDAP_DRIVER_PORT
- PARTKEEPR_FR3D_LDAP_DRIVER_USESSL
- PARTKEEPR_FR3D_LDAP_DRIVER_USESTARTTLS
- PARTKEEPR_FR3D_LDAP_DRIVER_USERNAME
- PARTKEEPR_FR3D_LDAP_USER_ATTRIBUTE_EMAIL
- PARTKEEPR_FR3D_LDAP_USER_ATTRIBUTE_USERNAME
- PARTKEEPR_FR3D_LDAP_USER_BASEDN
- PARTKEEPR_FR3D_LDAP_USER_ENABLED
- PARTKEEPR_FR3D_LDAP_USER_FILTER
- PARTKEEPR_LOCALE
- PARTKEEPR_MAILER_AUTH_MODE
- PARTKEEPR_MAILER_ENCRYPTION
- PARTKEEPR_MAILER_HOST
- PARTKEEPR_MAILER_PASSWORD
- PARTKEEPR_MAILER_PORT
- PARTKEEPR_MAILER_TRANSPORT
- PARTKEEPR_MAILER_USER
- PARTKEEPR_AUTH_MAX_USERS
- PARTKEEPR_CATEGORY_PATH_SEPARATOR
- PARTKEEPR_CRONJOB_CHECK
- PARTKEEPR_FILESYSTEM_DATA_DIRECTORY
- PARTKEEPR_FILESYSTEM_QUOTA
- PARTKEEPR_MAINTENANCE
- PARTKEEPR_MAINTENANCE_MESSAGE
- PARTKEEPR_MAINTENANCE_TITLE
- PARTKEEPR_OCTOPART_APIKEY
- PARTKEEPR_PARTS_INTERNALPARTNUMBERUNIQUE
- PARTKEEPR_PARTS_LIMIT
- PARTKEEPR_USERS_LIMIT
- PARTKEEPR_SECRET
ports:
- "80:80"
volumes:
Expand Down
54 changes: 48 additions & 6 deletions mkparameters
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,54 @@ $twig = new Twig_Environment($loader, array('cache' => '/tmp'));
$template = $twig->load($TEMPLATE_FILE);

$values = array(
'PARTKEEPR_DATABASE_HOST' => getenv('PARTKEEPR_DATABASE_HOST'),
'PARTKEEPR_DATABASE_NAME' => getenv('PARTKEEPR_DATABASE_NAME'),
'PARTKEEPR_DATABASE_PORT' => getenv('PARTKEEPR_DATABASE_PORT'),
'PARTKEEPR_DATABASE_USER' => getenv('PARTKEEPR_DATABASE_USER'),
'PARTKEEPR_DATABASE_PASS' => getenv('PARTKEEPR_DATABASE_PASS'),
'PARTKEEPR_OKTOPART_APIKEY' => getenv('PARTKEEPR_OKTOPART_APIKEY')
'PARTKEEPR_AUTHENTICATION_PROVIDER' => getenv('PARTKEEPR_AUTHENTICATION_PROVIDER') ?: 'PartKeepr.Auth.WSSEAuthenticationProvider',
'PARTKEEPR_CACHE_DOCTRINE' => getenv('PARTKEEPR_CACHE_DOCTRINE') ?: 'array',
'PARTKEEPR_CACHE_DUNGLAS' => getenv('PARTKEEPR_CACHE_DOCTRINE') ?: 'false',
'PARTKEEPR_DATABASE_HOST' => getenv('PARTKEEPR_DATABASE_DRIVER') ?: 'pdo_mysql',
'PARTKEEPR_DATABASE_HOST' => getenv('PARTKEEPR_DATABASE_HOST') ?: 'database',
'PARTKEEPR_DATABASE_NAME' => getenv('PARTKEEPR_DATABASE_NAME') ?: 'partkeepr',
'PARTKEEPR_DATABASE_PORT' => getenv('PARTKEEPR_DATABASE_PORT') ?: '3306',
'PARTKEEPR_DATABASE_USER' => getenv('PARTKEEPR_DATABASE_USER') ?: 'partkeepr',
'PARTKEEPR_DATABASE_PASS' => getenv('PARTKEEPR_DATABASE_PASS') ?: 'partkeepr',
'PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTCANONICALFORM' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTCANONICALFORM') ?: NULL,
'PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTDOMAINNAME' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTDOMAINNAME') ?: NULL,
'PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTDOMAINNAMESHORT' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTDOMAINNAMESHORT') ?: NULL,
'PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTFILTERFORMAT' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTFILTERFORMAT') ?: NULL,
'PARTKEEPR_FR3D_LDAP_DRIVER_BASEDN' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_BASEDN') ?: '',
'PARTKEEPR_FR3D_LDAP_DRIVER_BINDREQUIRESDN' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_BINDREQUIRESDN') ?: false,
'PARTKEEPR_FR3D_LDAP_DRIVER_HOST' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_HOST') ?: '127.0.0.1',
'PARTKEEPR_FR3D_LDAP_DRIVER_OPTREFERRALS' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_OPTREFERRALS') ?: NULL,
'PARTKEEPR_FR3D_LDAP_DRIVER_PASSWORD' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_PASSWORD') ?: NULL,
'PARTKEEPR_FR3D_LDAP_DRIVER_PORT' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_PORT') ?: 389,
'PARTKEEPR_FR3D_LDAP_DRIVER_USESSL' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_USESSL') ?: NULL,
'PARTKEEPR_FR3D_LDAP_DRIVER_USESTARTTLS' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_USESTARTTLS') ?: NULL,
'PARTKEEPR_FR3D_LDAP_DRIVER_USERNAME' => getenv('PARTKEEPR_FR3D_LDAP_DRIVER_USERNAME') ?: NULL,
'PARTKEEPR_FR3D_LDAP_USER_ATTRIBUTE_EMAIL' => getenv('PARTKEEPR_FR3D_LDAP_USER_ATTRIBUTE_EMAIL') ?: 'email',
'PARTKEEPR_FR3D_LDAP_USER_ATTRIBUTE_USERNAME' => getenv('PARTKEEPR_FR3D_LDAP_USER_ATTRIBUTE_USERNAME') ?: 'samaccountname',
'PARTKEEPR_FR3D_LDAP_USER_BASEDN' => getenv('PARTKEEPR_FR3D_LDAP_USER_BASEDN') ?: 'dc=example,dc=com',
'PARTKEEPR_FR3D_LDAP_USER_ENABLED' => getenv('PARTKEEPR_FR3D_LDAP_USER_ENABLED') ?: false,
'PARTKEEPR_FR3D_LDAP_USER_FILTER' => getenv('PARTKEEPR_FR3D_LDAP_USER_FILTER') ?: NULL,
'PARTKEEPR_LOCALE' => getenv('PARTKEEPR_LOCALE') ?: 'en',
'PARTKEEPR_MAILER_AUTH_MODE' => getenv('PARTKEEPR_MAILER_AUTH_MODE') ?: NULL,
'PARTKEEPR_MAILER_ENCRYPTION' => getenv('PARTKEEPR_MAILER_ENCRYPTION') ?: NULL,
'PARTKEEPR_MAILER_HOST' => getenv('PARTKEEPR_MAILER_HOST') ?: NULL,
'PARTKEEPR_MAILER_PASSWORD' => getenv('PARTKEEPR_MAILER_PASSWORD') ?: NULL,
'PARTKEEPR_MAILER_PORT' => getenv('PARTKEEPR_MAILER_PORT') ?: NULL,
'PARTKEEPR_MAILER_TRANSPORT' => getenv('PARTKEEPR_MAILER_TRANSPORT') ?: NULL,
'PARTKEEPR_MAILER_USER' => getenv('PARTKEEPR_MAILER_USER') ?: NULL,
'PARTKEEPR_AUTH_MAX_USERS' => getenv('PARTKEEPR_AUTH_MAX_USERS') ?: 'unlimited',
'PARTKEEPR_CATEGORY_PATH_SEPARATOR' => getenv('PARTKEEPR_CATEGORY_PATH_SEPARATOR') ?: '',
'PARTKEEPR_CRONJOB_CHECK' => getenv('PARTKEEPR_CRONJOB_CHECK') ?: true,
'PARTKEEPR_FILESYSTEM_DATA_DIRECTORY' => getenv('PARTKEEPR_FILESYSTEM_DATA_DIRECTORY') ?: '%kernel.root_dir%/../data/',
'PARTKEEPR_FILESYSTEM_QUOTA' => getenv('PARTKEEPR_FILESYSTEM_QUOTA') ?: false,
'PARTKEEPR_MAINTENANCE' => getenv('PARTKEEPR_MAINTENANCE') ?: '',
'PARTKEEPR_MAINTENANCE_MESSAGE' => getenv('PARTKEEPR_MAINTENANCE_MESSAGE') ?: '',
'PARTKEEPR_MAINTENANCE_TITLE' => getenv('PARTKEEPR_MAINTENANCE_TITLE') ?: '',
'PARTKEEPR_OCTOPART_APIKEY' => getenv('PARTKEEPR_OCTOPART_APIKEY') ?: NULL,
'PARTKEEPR_PARTS_INTERNALPARTNUMBERUNIQUE' => getenv('PARTKEEPR_PARTS_INTERNALPARTNUMBERUNIQUE') ?: false,
'PARTKEEPR_PARTS_LIMIT' => getenv('PARTKEEPR_PARTS_LIMIT') ?: false,
'PARTKEEPR_USERS_LIMIT' => getenv('PARTKEEPR_USERS_LIMIT') ?: false,
'PARTKEEPR_SECRET' => getenv('PARTKEEPR_SECRET') ?: 'OJBKOJIKNONAJENLBJJNLFIDPDGKDIED',
);

echo $template->render($values);
Expand Down
84 changes: 42 additions & 42 deletions parameters.template
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
<?php
$container->setParameter('authentication_provider', 'PartKeepr.Auth.WSSEAuthenticationProvider');
$container->setParameter('cache.doctrine', 'array');
$container->setParameter('cache.dunglas', false);
$container->setParameter('database_driver', 'pdo_mysql');
$container->setParameter('authentication_provider', '{{ PARTKEEPR_AUTHENTICATION_PROVIDER }}');
$container->setParameter('cache.doctrine', '{{ PARTKEEPR_CACHE_DOCTRINE }}');
$container->setParameter('cache.dunglas', '{{ PARTKEEPR_CACHE_DOCTRINE }}');
$container->setParameter('database_driver', '{{ PARTKEEPR_DATABASE_DRIVER }}');
$container->setParameter('database_host', '{{ PARTKEEPR_DATABASE_HOST }}');
$container->setParameter('database_name', '{{ PARTKEEPR_DATABASE_NAME }}');
$container->setParameter('database_password', '{{ PARTKEEPR_DATABASE_PASS }}');
$container->setParameter('database_port', {{ PARTKEEPR_DATABASE_PORT }});
$container->setParameter('database_user', '{{ PARTKEEPR_DATABASE_USER }}');
$container->setParameter('fr3d_ldap.driver.accountCanonicalForm', NULL);
$container->setParameter('fr3d_ldap.driver.accountDomainName', NULL);
$container->setParameter('fr3d_ldap.driver.accountDomainNameShort', NULL);
$container->setParameter('fr3d_ldap.driver.accountFilterFormat', NULL);
$container->setParameter('fr3d_ldap.driver.baseDn', '');
$container->setParameter('fr3d_ldap.driver.bindRequiresDn', false);
$container->setParameter('fr3d_ldap.driver.host', '127.0.0.1');
$container->setParameter('fr3d_ldap.driver.optReferrals', NULL);
$container->setParameter('fr3d_ldap.driver.password', NULL);
$container->setParameter('fr3d_ldap.driver.port', 389);
$container->setParameter('fr3d_ldap.driver.useSsl', NULL);
$container->setParameter('fr3d_ldap.driver.useStartTls', NULL);
$container->setParameter('fr3d_ldap.driver.username', NULL);
$container->setParameter('fr3d_ldap.user.attribute.email', 'email');
$container->setParameter('fr3d_ldap.user.attribute.username', 'samaccountname');
$container->setParameter('fr3d_ldap.user.baseDn', 'dc=example,dc=com');
$container->setParameter('fr3d_ldap.user.enabled', false);
$container->setParameter('fr3d_ldap.user.filter', NULL);
$container->setParameter('locale', 'en');
$container->setParameter('mailer_auth_mode', NULL);
$container->setParameter('mailer_encryption', NULL);
$container->setParameter('mailer_host', NULL);
$container->setParameter('mailer_password', NULL);
$container->setParameter('mailer_port', NULL);
$container->setParameter('mailer_transport', NULL);
$container->setParameter('mailer_user', NULL);
$container->setParameter('partkeepr.auth.max_users', 'unlimited');
$container->setParameter('partkeepr.category.path_separator', '');
$container->setParameter('partkeepr.cronjob.check', true);
$container->setParameter('partkeepr.filesystem.data_directory', '%kernel.root_dir%/../data/');
$container->setParameter('partkeepr.filesystem.quota', false);
$container->setParameter('partkeepr.maintenance', false);
$container->setParameter('partkeepr.maintenance.message', '');
$container->setParameter('partkeepr.maintenance.title', '');
$container->setParameter('fr3d_ldap.driver.accountCanonicalForm', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTCANONICALFORM }}');
$container->setParameter('fr3d_ldap.driver.accountDomainName', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTDOMAINNAME }}');
$container->setParameter('fr3d_ldap.driver.accountDomainNameShort', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTDOMAINNAMESHORT }}');
$container->setParameter('fr3d_ldap.driver.accountFilterFormat', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_ACCOUNTFILTERFORMAT }}');
$container->setParameter('fr3d_ldap.driver.baseDn', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_BASEDN }}');
$container->setParameter('fr3d_ldap.driver.bindRequiresDn', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_BINDREQUIRESDN }}');
$container->setParameter('fr3d_ldap.driver.host', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_HOST }}');
$container->setParameter('fr3d_ldap.driver.optReferrals', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_OPTREFERRALS }}');
$container->setParameter('fr3d_ldap.driver.password', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_PASSWORD }}');
$container->setParameter('fr3d_ldap.driver.port', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_PORT }}');
$container->setParameter('fr3d_ldap.driver.useSsl', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_USESSL }}');
$container->setParameter('fr3d_ldap.driver.useStartTls', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_USESTARTTLS }}');
$container->setParameter('fr3d_ldap.driver.username', '{{ PARTKEEPR_FR3D_LDAP_DRIVER_USERNAME }}');
$container->setParameter('fr3d_ldap.user.attribute.email', '{{ PARTKEEPR_FR3D_LDAP_USER_ATTRIBUTE_EMAIL }}');
$container->setParameter('fr3d_ldap.user.attribute.username', '{{ PARTKEEPR_FR3D_LDAP_USER_ATTRIBUTE_USERNAME }}');
$container->setParameter('fr3d_ldap.user.baseDn', '{{ PARTKEEPR_FR3D_LDAP_USER_BASEDN }}');
$container->setParameter('fr3d_ldap.user.enabled', '{{ PARTKEEPR_FR3D_LDAP_USER_ENABLED }}');
$container->setParameter('fr3d_ldap.user.filter', '{{ PARTKEEPR_FR3D_LDAP_USER_FILTER }}');
$container->setParameter('locale', '{{ PARTKEEPR_LOCALE }}');
$container->setParameter('mailer_auth_mode', '{{ PARTKEEPR_MAILER_AUTH_MODE }}');
$container->setParameter('mailer_encryption', '{{ PARTKEEPR_MAILER_ENCRYPTION }}');
$container->setParameter('mailer_host', '{{ PARTKEEPR_MAILER_HOST }}');
$container->setParameter('mailer_password', '{{ PARTKEEPR_MAILER_PASSWORD }}');
$container->setParameter('mailer_port', '{{ PARTKEEPR_MAILER_PORT }}');
$container->setParameter('mailer_transport', '{{ PARTKEEPR_MAILER_TRANSPORT }}');
$container->setParameter('mailer_user', '{{ PARTKEEPR_MAILER_USER }}');
$container->setParameter('partkeepr.auth.max_users', '{{ PARTKEEPR_AUTH_MAX_USERS }}');
$container->setParameter('partkeepr.category.path_separator', '{{ PARTKEEPR_CATEGORY_PATH_SEPARATOR }}');
$container->setParameter('partkeepr.cronjob.check', '{{ PARTKEEPR_CRONJOB_CHECK }}');
$container->setParameter('partkeepr.filesystem.data_directory', '{{ PARTKEEPR_FILESYSTEM_DATA_DIRECTORY }}');
$container->setParameter('partkeepr.filesystem.quota', '{{ PARTKEEPR_FILESYSTEM_QUOTA }}');
$container->setParameter('partkeepr.maintenance', '{{ PARTKEEPR_MAINTENANCE }}');
$container->setParameter('partkeepr.maintenance.message', '{{ PARTKEEPR_MAINTENANCE_MESSAGE }}');
$container->setParameter('partkeepr.maintenance.title', '{{ PARTKEEPR_MAINTENANCE_TITLE }}');
$container->setParameter('partkeepr.octopart.apikey', '{{ PARTKEEPR_OKTOPART_APIKEY }}');
$container->setParameter('partkeepr.parts.internalpartnumberunique', false);
$container->setParameter('partkeepr.parts.limit', false);
$container->setParameter('partkeepr.users.limit', false);
$container->setParameter('secret', 'OJBKOJIKNONAJENLBJJNLFIDPDGKDIED');
$container->setParameter('partkeepr.parts.internalpartnumberunique', '{{ PARTKEEPR_PARTS_INTERNALPARTNUMBERUNIQUE }}');
$container->setParameter('partkeepr.parts.limit', '{{ PARTKEEPR_PARTS_LIMIT }}');
$container->setParameter('partkeepr.users.limit', '{{ PARTKEEPR_USERS_LIMIT }}');
$container->setParameter('secret', '{{ PARTKEEPR_SECRET }}');

0 comments on commit 10fd81a

Please sign in to comment.