File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- FROM postgres:12 -alpine
1+ FROM postgres:17 -alpine
22
33WORKDIR /scripts
44
5+ COPY config/ /etc/postgresql/
6+ COPY scripts/configure_postgres.sh /docker-entrypoint-initdb.d/00_configure_postgres.sh
7+ RUN chown postgres:postgres /etc/postgresql/*.conf \
8+ && chmod 600 /etc/postgresql/*.conf \
9+ && chmod +x /docker-entrypoint-initdb.d/00_configure_postgres.sh
10+
511COPY scripts/setup_user.sql /scripts
612
713COPY scripts/salesdb /scripts/salesdb
Original file line number Diff line number Diff line change 1+ COMPOSE ?= docker compose
2+
13start :
24 make stop rm || true
35 docker run -it \
1719
1820bash :
1921 docker run --rm -it data-salesdb bash
22+
23+ compose-build :
24+ $(COMPOSE ) build
25+
26+ compose :
27+ $(COMPOSE ) up --abort-on-container-exit
28+
29+ compose-down :
30+ $(COMPOSE ) down -v --remove-orphans
31+
32+ compose-logs :
33+ $(COMPOSE ) logs -f
34+
35+ compose-ps :
36+ $(COMPOSE ) ps
37+
38+ compose-bash :
39+ $(COMPOSE ) run --rm postgres bash
40+
41+ compose-attach :
42+ $(COMPOSE ) exec postgres bash
Original file line number Diff line number Diff line change 1+ # TYPE DATABASE USER ADDRESS METHOD
2+
3+ local all postgres peer
4+ local all all scram-sha-256
5+ host all postgres 0.0.0.0/0 scram-sha-256
6+ host all postgres ::/0 scram-sha-256
7+ host all student 0.0.0.0/0 scram-sha-256
8+ host all student ::/0 scram-sha-256
9+ host all all 127.0.0.1/32 scram-sha-256
10+ host all all ::1/128 scram-sha-256
Original file line number Diff line number Diff line change 1+ listen_addresses = '*'
2+ password_encryption = 'scram-sha-256'
Original file line number Diff line number Diff line change 1+ services :
2+ postgres :
3+ build :
4+ context : .
5+ environment :
6+ POSTGRES_PASSWORD : secret
7+ ports :
8+ - " 5432:5432"
9+ volumes :
10+ - pgdata:/var/lib/postgresql/data
11+ healthcheck :
12+ test : ["CMD-SHELL", "pg_isready -U postgres -h 127.0.0.1"]
13+ interval : 10s
14+ timeout : 5s
15+ retries : 5
16+ start_period : 5s
17+
18+ volumes :
19+ pgdata :
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e
3+
4+ : " ${PGDATA:? PGDATA is not set} "
5+
6+ cp /etc/postgresql/postgresql.conf " $PGDATA /postgresql.conf"
7+ cp /etc/postgresql/pg_hba.conf " $PGDATA /pg_hba.conf"
8+ chmod 600 " $PGDATA /postgresql.conf" " $PGDATA /pg_hba.conf"
Original file line number Diff line number Diff line change 11version https://git-lfs.github.com/spec/v1
2- oid sha256:e8a5ceed973724a7ee842b467f6cc3b107110f98c0e472687f1fd3f9c4469797
3- size 12201348
2+ oid sha256:ac803445153c4f6f325a40bb36647d83c8c8f398701d66aab5b1ab9bfa74e70d
3+ size 14768668
Original file line number Diff line number Diff line change 1- REVOKE ALL ON schema public FROM public;
2- CREATE ROLE student WITH LOGIN PASSWORD ' student'
3- NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION VALID UNTIL ' infinity' ;
1+ DO
2+ $$
3+ BEGIN
4+ IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = ' student' ) THEN
5+ CREATE ROLE student
6+ WITH LOGIN PASSWORD ' student'
7+ NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;
8+ END IF;
9+ END;
10+ $$;
11+
12+ REVOKE ALL ON SCHEMA public FROM public;
13+
414GRANT USAGE ON SCHEMA public TO student;
515GRANT SELECT ON ALL TABLES IN SCHEMA public TO student;
616ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO student;
17+
18+ DO
19+ $$
20+ DECLARE
21+ dbname text := current_database();
22+ BEGIN
23+ EXECUTE format(' GRANT CONNECT ON DATABASE %I TO student' , dbname);
24+ EXECUTE format(' GRANT TEMP ON DATABASE %I TO student' , dbname);
25+ END;
26+ $$;
You can’t perform that action at this time.
0 commit comments