In caprover, formerly captainduckduck, I had the issue that the database and a user were not created by setting environment variables MYSQL_USER
and MYSQL_DATABASE
.
While building, this message was displayed by Docker:
[Warning] One or more build-args [MYSQL_USER, MYSQL_DATABASE] were not consumed
So appearently, Caprover does not support setting the environment variables for (only?) MySQL anymore.
Selecting MySQL from the oneclick-apps gives you the following options.
Note the absence of setting extra environment variables.
You can only set the root password.
When you start this new app, only the root password is set. If you now set the environment variables, MySQL will not create the database or user. It does this only on first startup, after creating the one-click-app for MySQL.
My workaround? Don’t use a one-click app and supply a Dockerfile directly inside Caprover instead.
This is what I used:
ENV MYSQL_ROOT_PASSWORD=S3cretR00t ENV MYSQL_DATABASE=dbname_for_app ENV MYSQL_USER=app_user ENV MYSQL_PASSWORD=An0therS3cret
When you deploy your new database app now, the database and the user will be created.
TIP: after this, you won’t see the Dockerfile contents anymore. So in the future it might be unclear what values were set.
In order to overcome this, set the environment variables as well over at App Configs > Environmental variables:
MYSQL_ROOT_PASSWORD=S3cretR00t MYSQL_DATABASE=dbname_for_app MYSQL_USER=app_user MYSQL_PASSWORD=An0therS3cret
That’s it! Now let’s hope we’ll be able to set environment variables in the one-click setup some day soon again.