louislam / uptime-kuma

A fancy self-hosted monitoring tool

Home Page:https://uptime.kuma.pet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generate Database without launching the server

tedivm opened this issue Β· comments

⚠️ Please verify that this question has NOT been raised before.

  • I checked and didn't find similar issue

πŸ›‘οΈ Security Policy

πŸ“ Describe your problem

Is there a way to generate the database/migrations without launching the server? I'm hoping to follow this flow:

  1. Generate Database
  2. Due custom stuff to database
  3. Launch server

I'm not as used to javascript as I am other languages like python so I'm running into some difficulty figuring out how to just create the database. Any help would be appreciated!

πŸ“ Error Message(s) or Log

No response

🐻 Uptime-Kuma Version

1.23.13

πŸ’» Operating System and Arch

Docker

🌐 Browser

Firefox

πŸ–₯️ Deployment Environment

  • Runtime:
  • Database:
  • Filesystem used to store the database on:
  • number of monitors:

I think this is an XY-Problem.

=> What are you trying to do in the first place? You forgot the WHY.

Reaching into the database is the most brittle way to configure us that I can think of.
You are inherently making yourself tied to a minor version and cannot expect us to respect semver for internal behaviour (such as db layout).

Tip

In case you are looking for an API, please have a look at BigBoot/AutoKuma (cli or docker automation) or uptime-kuma-api
An official REST-API is coming, but is a few releases off still. See #118 for further details

The why is simple: I want to be able to bootstrap a bunch of images at once without having to manually configure them. I'm okay with tying myself to a minor version for the initial launch.

Here's a simple use case. I would like to set the username and password for the inital admin user programmatically. The "npm run reset-password" script only works if the database is already configured.

  1. Create Database
  2. Set password using built in script
  3. Continue launching server

This use case requires no direct database changes or access, and simply uses the scripts provided to ensure the first admin users are created before opening connections up to anyone.

you can generate the intial databas via

export DOCKER_ID=`docker run --rm -d -v ./uptime-kuma:/app/data louislam/uptime-kuma:1 | tail -1`
sleep 60 # higher than nessesary, can be tuned 
docker stop $DOCKER_ID