What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hello, how is it possible with the docker/sdk to use an external database instead of the docker imag
Hello, how is it possible with the docker/sdk to use an external database instead of the docker image?
Comments
-
you should be able to configure another database via the
config_default-X.php
$config[PropelConstants::ZED_DB_HOST] = 'external_host_name_or_ip';
0 -
Agree. Just provide your external db credentials via env vars.
0 -
is this somehow documented? what are the parameter for user?
0 -
should i create this file?
0 -
Check config/Shared/config_default.php as an example.
It has something like
$config[PropelConstants::ZED_DB_ENGINE] = $config[PropelQueryBuilderConstants::ZED_DB_ENGINE] = strtolower(getenv('SPRYKER_DB_ENGINE') ?: '') ?: PropelConfig::DB_ENGINE_PGSQL; $config[PropelConstants::ZED_DB_HOST] = getenv('SPRYKER_DB_HOST'); $config[PropelConstants::ZED_DB_PORT] = getenv('SPRYKER_DB_PORT'); $config[PropelConstants::ZED_DB_USERNAME] = getenv('SPRYKER_DB_USERNAME'); $config[PropelConstants::ZED_DB_PASSWORD] = getenv('SPRYKER_DB_PASSWORD'); $config[PropelConstants::ZED_DB_DATABASE] = getenv('SPRYKER_DB_DATABASE'); $config[PropelConstants::ZED_DB_REPLICAS] = json_decode(getenv('SPRYKER_DB_REPLICAS') ?: '[]', true); $config[PropelConstants::USE_SUDO_TO_MANAGE_DATABASE] = false;
Env var for user for example is SPRYKER_DB_USERNAME.
0 -
Check the docs for how to set env vars via deploy file: https://documentation.spryker.com/docs/deploy-file-reference-10
0 -
many thanks, i see now ZED_DB_USERNAME and ZED_DB_PASSWord for our postgres setuop, but i dont get it how in the file is written ZED_DB_USERNAME and then you say SPRYKER_DB_USERNAME as variable
0 -
aaaaahhhhh
0 -
i got it now with the variables π
0 -
Follow the documentation. Add your env vars to e. g. deploy.dev.yml, then run
docker/sdk bootstrap deploy.dev.yml docker/sdk up
Then, you should be able to use your env var values in config_default.php.
0 -
I'm assuming that you're using the docker/sdk. In case your changes are needed for local development as a start, I'd recommend to use deploy.dev.yml for configuring env vars. This will affect your local env only.
Also be aware that security-wise it's really bad to have credentials in yml files and commit them to your code repository. Unfortunately, Spryker doesn't offer anything better out of the box. At least nothing that I'm aware of.We decided to use Dotenv to load local .env files instead of adding sensitive env vars to deploy files. Those .env files aren't committed to the code repo. But I leave that up to you, just mentioning.
0 -
Yeah I first need to get warmth with this. π
When i once understand how it works we will move the credentials to local .env
0 -
I can recommend to use composer package
symfony/dotenv
.
Then in e. g. config_default do$dotenv = new Dotenv(); $dotenv->usePutenv(); $dotenv->load(sprintf('%s/../../.env.local', __DIR__));
Then you can get your env vars via
getenv()
.0 -
where in the deploy.yml need i to put
SPRYKER_DB_ENGINE: "DB_ENGINE_PGSQL" SPRYKER_DB_HOST: "xxxx" SPRYKER_DB_PORT: "5432" SPRYKER_DB_USERNAME: "xxxx" SPRYKER_DB_PASSWORD: "xxxx" SPRYKER_DB_DATABASE: "postgres"
? in your mention documentation i can't flolow where to put this. Otherwise please show with heading line i need to re-read
0 -
-
ah merci
0 -
i did this now and following error happens:
`Running generator PHP Notice: Undefined index: DE in /data/index.php on line 210 PHP Notice: Undefined index: DE in /data/index.php on line 303 PHP Warning: array_replace_recursive(): Expected parameter 1 to be an array, null given in /data/index.php on line 304 PHP Notice: Undefined index: DE in /data/index.php on line 318 PHP Notice: Undefined index: DE in /data/index.php on line 210 PHP Fatal error: Uncaught Twig\Error\LoaderError: Template "env/database/.env.twig" is not defined in "env/application/zed.env.twig" at line 25. in /data/vendor/twig/twig/src/Loader/ChainLoader.php:98 Stack trace: #0 /data/vendor/twig/twig/src/Environment.php(299): Twig\Loader\ChainLoader->getCacheKey('env/database/.e...') #1 /data/vendor/twig/twig/src/Environment.php(381): Twig\Environment->getTemplateClass('env/database/.e...') #2 /data/vendor/twig/twig/src/Template.php(335): Twig\Environment->loadTemplate('env/database/.e...', NULL) #3 /data/vendor/twig/twig/src/Environment.php(418) : eval()'d code(68): Twig\Template->loadTemplate('env/database/.e...', 'env/application...', 25) #4 /data/vendor/twig/twig/src/Template.php(407): __TwigTemplate_64e7675df8da3481952f197c98ec39fc33132be6d48b6a901bfbd8429e3ca59d->doDisplay(Array, Array) #5 /data/vendor/twig/twig/src/Template.php(380): Twig\Template->displayWithErrorHandling(Array, Array) #6 /data/vendor/twig/twig/src/Template.php(392): Twig\Template->display(Array) #7 /data/vendor in /data/vendor/twig/twig/src/Loader/ChainLoader.php on line 98
0 -
Hm... I think it still tries to init the local db that you don't want to use.
Check if removing the services > database from deploy-dev.yml helps.There's still a chance that it's not that easy to connect an external db. I'm just guessing, too. Maybe somebody from Spryker can jump in and enlighten us.
0 -
Sadly not the database service i removed before
0 -
@U01R7S9AABE fyi
0 -
@U01LKKBK97T do you have a working deploy.yml which you could anomyze and send us?
0 -
with this external db variables?
0 -
No. We're connecting to the db the standard way, haven't done what you're trying to achieve.
Our env vars for local environment are all taken from .env.local.0 -
what isn't working exactly? you should be able just to edit the config and it should connect
0 -
the bootstrap is not working with following deploy.yml file
0 -
It wonβt work this way. All the env vars defined in image (in deploy.yml) will be overridden by env vars coming from docker.
You need to remap env vars (use new custom ones) in config_default⦠and then you can set them in deploy.yml.
According the error. You still need database defined in deploy.yml. docker/sdk cannot work without it at the moment. And it wonβt be a problem for you if you have custom config for the database.
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random