Skip to content

Commit 1df9aaa

Browse files
feat(command): Add postgres - psql, pg_dump, pg_dumpall
1 parent 2403d4d commit 1df9aaa

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ PROTOC_VERSION=3.9.1
3636
PROTOC_ARCH=${DEFAULT_ARCH}
3737
PROTOC_BASE=${DEFAULT_BASE}
3838
POSTGRES_VERSION=14.2
39-
PSQL_VERSION=${POSTGRES_VERSION}
4039
PYTHON_VERSION=3.10
4140
PYTHON2_VERSION=2.7.18
4241
RUBY_VERSION=3.1.1

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ dockerized <command>
2323
- Database
2424
- dolt
2525
- mysql
26+
- [postgres](apps/postgres/README.md)
27+
- psql
28+
- pg_dump
29+
- pg_dumpall
2630
- Dev-Ops & Docker
2731
- ansible
2832
- ansible-playbook

apps/postgres/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# dockerized postgres
2+
3+
You can use dockerized postgres to query your database, and manage backups, without locally installing postgres.
4+
5+
The commands work as usual, except:
6+
7+
- Use `host.docker.internal` instead of `localhost`.
8+
- You can only access files in the current working directory (e.g. when dumping).
9+
10+
## psql
11+
12+
```shell
13+
dockerized psql --host "host.docker.internal" --username <username>
14+
```
15+
16+
## pg_dumpall
17+
18+
```shell
19+
dockerized pg_dumpall \
20+
--host "host.docker.internal" \
21+
--file "backup.sql" \
22+
--username root \
23+
--no-password \
24+
--quote-all-identifiers \
25+
--verbose
26+
```

docker-compose.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,14 @@ services:
156156
php:
157157
image: "php:${PHP_VERSION}"
158158
psql:
159-
image: "postgres:${PSQL_VERSION}"
159+
image: "postgres:${POSTGRES_VERSION}"
160160
entrypoint: [ "psql" ]
161+
pg_dump:
162+
image: "postgres:${POSTGRES_VERSION}"
163+
entrypoint: [ "pg_dump" ]
164+
pg_dumpall:
165+
image: "postgres:${POSTGRES_VERSION}"
166+
entrypoint: [ "pg_dumpall" ]
161167
protoc:
162168
image: "protoc:${PROTOC_VERSION}"
163169
build:

0 commit comments

Comments
 (0)