1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-11-24 20:06:55 +01:00

chore: slightly simpler quick start setup (#10933)

Co-authored-by: Melinda Fekete <melinda.fekete@getunleash.io>
This commit is contained in:
Simon Hornby 2025-11-11 17:10:27 +02:00 committed by GitHub
parent 1fc39ade33
commit c5f0b50b30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 61 additions and 1 deletions

View File

@ -0,0 +1,21 @@
services:
unleash-postgres:
build:
context: ./docker/local-postgres
container_name: unleash-postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
ports:
- "5432:5432"
volumes:
- unleash-postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 12
volumes:
unleash-postgres-data:

View File

@ -0,0 +1,3 @@
FROM postgres:15
COPY init-unleash.sql /docker-entrypoint-initdb.d/init-unleash.sql

View File

@ -0,0 +1,24 @@
\set ON_ERROR_STOP on
DO
$$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_catalog.pg_roles WHERE rolname = 'unleash_user') THEN
CREATE ROLE unleash_user LOGIN PASSWORD 'password';
END IF;
END
$$;
ALTER ROLE unleash_user CREATEDB;
SELECT 'CREATE DATABASE unleash WITH OWNER unleash_user'
WHERE NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'unleash');
\gexec
SELECT 'CREATE DATABASE unleash_test WITH OWNER unleash_user'
WHERE NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'unleash_test');
\gexec
SELECT 'ALTER DATABASE unleash_test SET timezone TO ''UTC'''
WHERE EXISTS (SELECT 1 FROM pg_database WHERE datname = 'unleash_test');
\gexec

View File

@ -30,7 +30,19 @@ To run and develop Unleash, you need to have PostgreSQL 14.0+ locally.
Unleash currently also works with PostgreSQL v14.0+, but this might change in a future feature release, and we have stopped running automatic integration tests below PostgreSQL 14. The current recommendation is to use a role with Owner privileges since Unleash uses Postgres functions to simplify our database usage.
### Create a local unleash databases in postgres {#create-a-local-unleash-databases-in-postgres}
### Create a local Unleash database in Postgres
Start the ready-to-use Postgres container (first run builds a small image that
executes the required SQL automatically):
```bash
$ docker compose -f docker-compose.postgres.yml up -d
```
The container exposes Postgres on `localhost:5432` with the expected role and
databases already created. Stop it with `docker compose -f docker-compose.postgres.yml down`.
If you prefer to run the SQL manually outside of Docker, you can execute:
```bash
$ psql postgres <<SQL