Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create user on docker compose startup #1575

Open
huksley opened this issue Feb 26, 2025 · 1 comment
Open

How to create user on docker compose startup #1575

huksley opened this issue Feb 26, 2025 · 1 comment
Labels

Comments

@huksley
Copy link

huksley commented Feb 26, 2025

I want to run docker compose setup and create a predefined user with username and password I specifiy in env variables. How I can do that?

Something like this???

configurator:
    command:
        bench example-set-username ${ADMIN_EMAIL}
        bench example-set-password ${ADMIN_PASSWORD}
@revant
Copy link
Collaborator

revant commented Feb 26, 2025

Move it at the end of create-site. User can only be added after site is available.

...
  create-site:
    ...
    command:
      - >
        wait-for-it -t 120 db:3306;
        wait-for-it -t 120 redis-cache:6379;
        wait-for-it -t 120 redis-queue:6379;
        export start=`date +%s`;
        until [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && \
          [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_cache // empty"` ]] && \
          [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_queue // empty"` ]];
        do
          echo "Waiting for sites/common_site_config.json to be created";
          sleep 5;
          if (( `date +%s`-start > 120 )); then
            echo "could not find sites/common_site_config.json with required keys";
            exit 1
          fi
        done;
        echo "sites/common_site_config.json found";
        bench new-site --mariadb-user-host-login-scope='%' --admin-password=admin --db-root-username=root --db-root-password=admin --install-app erpnext --set-default frontend;
        bench --site frontend add-system-manager --password=Secret@1234 admin@change.it;
        bench --site frontend add-user --password=Secret@4321 user@change.it;

Above is from pwd.yml. Execute after the site frontend is created. You must add system manager or first user may become system manager just like setup wizard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants