Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Automate user creation to use with Docker

admin

Started by Nikola Radovanovic 7 years ago · 5 replies · 842 views
7 years ago

Hi,
I have one question: I created small Docker script to build the image with Grav. Everything works fine except I cant add admin user automatically, as part of the build procedure. I have tried to use cat and echo to automate usage of admin plugin, but resulting file is not OK so I am prevented to login.

Am I missing something or I shall create user file directly (in which case I am not sure how to properly generate password hash)?

Thank you kindly

7 years ago

Hi @nikoladsp, I don't know anything about Docker, but it might help you to know that you can define a default unhashed password in a user.yaml file and after that first login it will be properly hashed.

So, for example if in your created user.yaml file you have this:
password: <yourpasswordhere>

After first login it will change to this:
hashed_password: <hashedpasswordhere>

I hope the above might be of help.
Paul

7 years ago

Thanks - I did not know this; I might use it and immediately call login using the curl. Is there any sample on how to login using curl?

Best regards

👍 1
7 years ago

you can create a user file (with hashed or cleartext password, as Paul already mentioned) before and then just copy that into the docker container (use 'docker cp' command for that).
Or, even easier, mount the whole webroot folder locally, then everything in there will be synchronized from/to container.
as an example, just look at the docker-compose.yml file at my GitHub Docker Project

👍 1
7 years ago

Thank you all for the answers. I created entry for user in Dockerfile with cleartext password and it works!

Best regards

👍 1

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 60 16 hours ago
Support · by Anna, 3 days ago
2 66 19 hours ago
Support · by Justin Young, 20 hours ago
1 34 20 hours ago
Support · by Duc , 1 week ago
2 70 6 days ago
Support · by Colin Hume, 1 week ago
2 61 6 days ago