Skip to content

Commit 7a841dd

Browse files
committed
Adds script to run postgres + ssl locally (on port 5433)
1 parent b55ff9d commit 7a841dd

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
.\#
22
*\#*\#
3+
.DS_Store
4+
run_postgres_ssl/*.pem
5+
run_postgres_ssl/*.crt
6+
run_postgres_ssl/*.key
7+
run_postgres_ssl/*.req

run_postgres_ssl/docker-compose.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '2'
2+
3+
services:
4+
postgres:
5+
container_name: postgres
6+
ports:
7+
- "5433:5432"
8+
image: 'postgres:12-alpine'
9+
environment:
10+
- POSTGRES_HOST_AUTH_METHOD=trust
11+
- POSTGRES_PASSWORD=password
12+
volumes:
13+
- '$PWD/server.crt:/var/lib/postgresql/server.crt:ro'
14+
- '$PWD/server.key:/var/lib/postgresql/server.key:ro'
15+
- '$PWD/pg_hba.conf:/var/lib/postgresql/pg_hba.conf'
16+
command: postgres -c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key

run_postgres_ssl/run_postgres_ssh.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
openssl req -new -text -passout pass:abcd -subj /CN=localhost -out server.req -keyout privkey.pem
6+
7+
openssl rsa -in privkey.pem -passin pass:abcd -out server.key
8+
9+
openssl req -x509 -in server.req -text -key server.key -out server.crt
10+
11+
chmod 600 server.key
12+
13+
test $(uname -s) = Linux && chown 70 server.key
14+
15+
echo '--------------------------------------------------'
16+
echo 'To Connect, Run:'
17+
echo ''
18+
echo 'psql -p 5433 "sslmode=verify-full host=localhost dbname=postgres user=postgres"'
19+
echo ''
20+
echo '--------------------------------------------------'
21+
22+
PWD=$(pwd) docker-compose up --force-recreate

0 commit comments

Comments
 (0)