Skip to content

Commit 6e6b283

Browse files
committed
Documentation improvement and CI additions.
2 parents b36c414 + 11c4518 commit 6e6b283

File tree

6 files changed

+432
-0
lines changed

6 files changed

+432
-0
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.git
2+
Dockerfile*

.gitlab-ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
3+
stages:
4+
- build
5+
- run
6+
- test
7+
- publish
8+
9+
before_script:
10+
- docker info
11+
12+
pre_clean:
13+
stage: build
14+
script:
15+
- docker stop gl-pgdd && docker rm gl-pgdd
16+
allow_failure: true
17+
18+
build_image:
19+
stage: build
20+
script:
21+
- docker build -t rustprooflabs/pgdd .
22+
23+
start_container:
24+
stage: run
25+
script:
26+
- docker run --name gl-pgdd -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD -p $PG_PORT:5432 -d rustprooflabs/pgdd
27+
- sleep 8
28+
29+
30+
query_extension:
31+
stage: test
32+
script:
33+
- PGPASSWORD=$POSTGRES_PASSWORD psql -h $PG_HOST -p $PG_PORT -U postgres -c "CREATE EXTENSION pgdd;"
34+
- PGPASSWORD=$POSTGRES_PASSWORD psql -h $PG_HOST -p $PG_PORT -U postgres -c "SELECT t_name FROM dd.tables;"
35+
- docker stop gl-pgdd
36+
- docker rm gl-pgdd
37+
38+
39+
create_non_extension_scripts:
40+
stage: publish
41+
script:
42+
- cat pgdd--0.1.sql > pgdd_v0_2.sql
43+
- cat pgdd--0.1--0.2.sql >> pgdd_v0_2.sql
44+
artifacts:
45+
paths:
46+
- pgdd_v0_2.sql
47+
48+
49+
...

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM postgres:12
2+
3+
ENV PG_MAJOR 12
4+
5+
LABEL maintainer="PgDD Project - https://github.com/rustprooflabs/pgdd"
6+
7+
RUN apt-get update \
8+
&& apt-cache showpkg postgresql-$PG_MAJOR \
9+
&& apt-get install -y --no-install-recommends \
10+
make \
11+
postgresql-server-dev-$PG_MAJOR \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
WORKDIR /tmp/pgdd
15+
COPY *.sql ./
16+
COPY pgdd.control ./
17+
COPY Makefile ./
18+
19+
RUN make install
20+

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ The PostgreSQL Data Dictionary (`pgdd`) is an in-database solution to provide
44
introspection via standard SQL query syntax. This extension makes it easy to
55
provide a usable data dictionary to all users of a PostgreSQL database.
66

7+
## Compatability
8+
9+
PgDD has been tested and found to work against PostgreSQL 10
10+
through 13-beta2.
11+
12+
Docker images available on
13+
[Docker Hub](https://hub.docker.com/r/rustprooflabs/pgdd).
14+
715

816
## Install `pgdd`
917

@@ -42,6 +50,73 @@ psql -d your_db
4250
CREATE EXTENSION pgdd;
4351
```
4452

53+
## Docker Image
54+
55+
Build Docker image. Uses [main Postgres image](https://hub.docker.com/_/postgres/) as starting point, see that
56+
repo for full instructions on using the core Postgres functionality.
57+
58+
```
59+
docker build -t rustprooflabs/pgdd .
60+
```
61+
62+
Build with tag.
63+
64+
Run Postgres in Docker.
65+
66+
```
67+
docker run --name test-pgdd12 -e POSTGRES_PASSWORD=mysecretpassword -p 6512:5432 -d rustprooflabs/pgdd
68+
```
69+
70+
Connect via `psql` using `postgres` role, provide password from prior step
71+
when prompted.
72+
73+
```
74+
psql -h host_or_ip -p 6512 -U postgres
75+
```
76+
77+
78+
79+
## Database Permissions
80+
81+
Create Read-only group role to assign to users
82+
that need access to query (read-only) the PgDD objects.
83+
84+
```
85+
CREATE ROLE dd_read WITH NOLOGIN;
86+
COMMENT ON ROLE dd_read IS 'Group role to grant read-only permissions to PgDD views.';
87+
88+
GRANT USAGE ON SCHEMA dd TO dd_read;
89+
GRANT SELECT ON ALL TABLES IN SCHEMA dd TO dd_read;
90+
ALTER DEFAULT PRIVILEGES IN SCHEMA dd GRANT SELECT ON TABLES TO dd_read;
91+
```
92+
93+
Access can now be granted to other users using:
94+
95+
```
96+
GRANT dd_read TO <your_login_user>;
97+
```
98+
99+
For read-write access.
100+
101+
102+
```
103+
CREATE ROLE dd_readwrite WITH NOLOGIN;
104+
COMMENT ON ROLE dd_readwrite IS 'Group role to grant write permissions to PgDD objects.';
105+
106+
GRANT dd_read TO dd_readwrite;
107+
108+
GRANT INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA dd TO dd_readwrite;
109+
ALTER DEFAULT PRIVILEGES IN SCHEMA dd GRANT INSERT, UPDATE, DELETE ON TABLES TO dd_readwrite;
110+
```
111+
112+
This access can be granted using:
113+
114+
```
115+
GRANT dd_readwrite TO <your_login_user>;
116+
```
117+
118+
119+
45120
## Use Data Dictionary
46121

47122
Connect to your database using your favorite SQL client. This

standalone/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The `.sql` files in this directory enable non-extension
2+
installations. This is useful for PGaaS (Postgres as a Service) installations such as AWS RDS.

0 commit comments

Comments
 (0)