I’m trying to automate the setup of our self-hosted n8n instance. We need to create an admin account with specific settings to obtain an API key for our deployment pipeline, testing, and production environments. I’ve set up a docker-compose configuration using a custom Postgres database, but I’m unsure how to automatically create the owner account.
I’ve reviewed the documentation but couldn’t find a method to automate this process. Is there a way to set up the admin account programmatically, perhaps through environment variables or a startup script?
hey stella, i ran into this too. n8n doesn’t support auto-admin setup, so i added a script to run post-container startup that uses the cli to create the admin. it’s not perfect but works for my case. hit me up if needed.
I’ve encountered this challenge before. In our setup, instead of modifying the main n8n container, we built a custom init container that runs before n8n starts. This container, based on a lightweight Alpine image with the n8n CLI installed, connects to our database and checks for the presence of an admin account, creating it if needed. We pass the admin credentials via environment variables in our configuration. This streamlined our deployment and maintained a clean main image, even though it adds a bit of extra complexity.
I encountered a similar challenge when setting up our n8n instance. While there’s no built-in method for automatic admin configuration, we developed a workaround using a combination of environment variables and a custom entrypoint script.
Our approach involves setting predefined environment variables for the admin credentials in the docker-compose file. Then, we created a custom Docker image that extends the official n8n image and includes an entrypoint script. This script checks if an admin account exists and creates one if not, using the n8n CLI.
It’s not an ideal solution, as it requires maintaining a custom image, but it’s been reliable for our CI/CD pipeline. If you’re interested, I can share more details about our implementation.