You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* rework preloading data section
* rework user creation section
* remove .zst as supported files
Co-authored-by: Max <max@cedardb.com>
---------
Co-authored-by: Max <max@cedardb.com>
Then connect from the same host using the domain socket:
103
-
```shell
104
-
docker exec -it cedardb psql -U postgres
105
-
```
106
-
Once connected, you can [manually create users and databases](/docs/references/sqlreference/statements/createrole):
107
-
```sql
108
-
create user {{username}} superuser with password '1234';
109
-
create database {{username}};
107
+
You can manage such files using [Docker secrets](https://docs.docker.com/engine/swarm/secrets/).
108
+
109
+
### Initialization scripts
110
+
111
+
CedarDB supports auto-initializing a new database with SQL and shell scripts. Additionally, the docker image accepts `xz` or `gzip` compressed SQL files.
112
+
Files in `/docker-entrypoint-initdb.d/` are executed or sourced during container setup. Supported file extensions are `.sh`, `.sql`, `.sql.xz` and `sql.gz`.
113
+
114
+
`.sh` files can use the `process_sql` function to run modified SQL statements that need shell pre-processing, e.g. by expanding shell or env variables.
115
+
116
+
#### Example: Creating an additional user at DB initialization
117
+
118
+
Initialization files let you create additional [users and databases](/docs/references/sqlreference/statements/createrole) during first-time setup. Provide usernames and passwords via environment variables or Docker secrets.
119
+
120
+
```shell {filename="users/create-user.sh"}
121
+
#!/bin/bash
122
+
set -e
123
+
124
+
process_sql <<-EOSQL
125
+
create role ${NEW_USER} login with password '${NEW_USER_PWD}';
126
+
create database ${NEW_USER};
127
+
EOSQL
110
128
```
111
129
112
-
#### Docker secrets
130
+
Then run:
113
131
114
-
CedarDB can also read credentials from files, ideal for secret management:
0 commit comments