Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Create the admin user as a separate command (#233)
Jake Howardff9e4b444b46
diff --git a/HOSTING.md b/HOSTING.mdindex f7001ca8fe..975a1edf19 100644--- a/HOSTING.md+++ b/HOSTING.md@@ -35,13 +35,13 @@ The repo supplies with a [Docker Compose](./docker-compose.yml) file and the samdocker-compose down```-- After the setup, you can start plausible as --+- After the setup, you can start plausible as --```bash- docker-compose up -d plausible+ docker-compose up -d plausible```- after a successful startup (can take upto 5 mins), `plausible` is available at port `80`, navigate to [`http://localhost`](http://localhost).--- stopping plausible --+ after a successful startup (can take upto 5 mins), `plausible` is available at port `80`, navigate to [`http://localhost`](http://localhost).++- stopping plausible --```bashdocker-compose down```@@ -51,12 +51,12 @@ The repo supplies with a [Docker Compose](./docker-compose.yml) file and the samdocker volume rm plausible_event-data -fdocker volume rm plausible_db-data -f```-Note:+Note:- #1 you need to stop plausible and restart plausible if you change the environment variables.- #2 With docker-compose, you need to remove the existing container and rebuild if you want your changes need to be reflected:```bashdocker rmi -f plausible_plausible:latest- docker-compose up -d plausible+ docker-compose up -d plausible```### Non-docker buildingIt is possible to create a release artifact by running a release.@@ -78,6 +78,7 @@ After the release, these are available under `_build/prod/rel/plausible` --```bash_build/prod/rel/plausible/createdb.sh+_build/prod/rel/plausible/init-admin.sh_build/prod/rel/plausible/migrate.sh_build/prod/rel/plausible/rollback.sh_build/prod/rel/plausible/seed.sh@@ -87,6 +88,7 @@ the same is available in the docker images as follows --```bashdocker run plausible:master-12add db createdb+docker run plausible:master-12add db init-admindocker run plausible:master-12add db migratedocker run plausible:master-12add db rollbackdocker run plausible:master-12add db seed@@ -120,7 +122,7 @@ Following are the variables that can be used to configure the availability of th- Disables changing of subscription and removes the trial notice banner (use with caution!) _defaults to `false`_### Default User Generation-For self-hosting, a default user is generated during the [Database Migration](#Database Migration) to access Plausible. To be noted that, a default user is a user whose trial period expires in 100 Years ;).+For self-hosting, a default user can be generated using the `db init-admin` command. To be noted that, a default user is a user whose trial period expires in 100 Years ;).It is *highly* recommended that you configure these parameters.- ADMIN_USER_NAMEdiff --git a/docker-compose.yml b/docker-compose.ymlindex 4c7c5ef732..368bed9c0f 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -38,7 +38,7 @@ services:build:context: .dockerfile: ./Dockerfile- command: sh -c "sleep 10 && /entrypoint.sh run"+ command: sh -c "sleep 10 && /entrypoint.sh db migrate && /entrypoint.sh run"depends_on:- plausible_db- plausible_events_db@@ -57,7 +57,7 @@ services:build:context: .dockerfile: ./Dockerfile- command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate"+ command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin"depends_on:- plausible_db- plausible_events_dbdiff --git a/lib/plausible_release.ex b/lib/plausible_release.exindex 21d4ef3b72..857438f716 100644--- a/lib/plausible_release.ex+++ b/lib/plausible_release.ex@@ -36,7 +36,6 @@ defmodule Plausible.Release dodef migrate doprepare()Enum.each(repos(), &run_migrations_for/1)- init_admin()prepare_clickhouse()run_migrations_for_ch()IO.puts("Migrations successful!")diff --git a/rel/overlays/init-admin.sh b/rel/overlays/init-admin.shnew file mode 100755index 0000000000..5d64ec6d4e--- /dev/null+++ b/rel/overlays/init-admin.sh@@ -0,0 +1,6 @@+#!/bin/sh+# Create an admin user++BIN_DIR=`dirname "$0"`++${BIN_DIR}/bin/plausible eval Plausible.Release.init_admin