Skip to content

Commit

Permalink
feat(command): Add postgres - psql, pg_dump, pg_dumpall
Browse files Browse the repository at this point in the history
  • Loading branch information
boukeversteegh committed May 22, 2022
1 parent 2403d4d commit 1df9aaa
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ PROTOC_VERSION=3.9.1
PROTOC_ARCH=${DEFAULT_ARCH}
PROTOC_BASE=${DEFAULT_BASE}
POSTGRES_VERSION=14.2
PSQL_VERSION=${POSTGRES_VERSION}
PYTHON_VERSION=3.10
PYTHON2_VERSION=2.7.18
RUBY_VERSION=3.1.1
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ dockerized <command>
- Database
- dolt
- mysql
- [postgres](apps/postgres/README.md)
- psql
- pg_dump
- pg_dumpall
- Dev-Ops & Docker
- ansible
- ansible-playbook
Expand Down
26 changes: 26 additions & 0 deletions apps/postgres/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# dockerized postgres

You can use dockerized postgres to query your database, and manage backups, without locally installing postgres.

The commands work as usual, except:

- Use `host.docker.internal` instead of `localhost`.
- You can only access files in the current working directory (e.g. when dumping).

## psql

```shell
dockerized psql --host "host.docker.internal" --username <username>
```

## pg_dumpall

```shell
dockerized pg_dumpall \
--host "host.docker.internal" \
--file "backup.sql" \
--username root \
--no-password \
--quote-all-identifiers \
--verbose
```
8 changes: 7 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,14 @@ services:
php:
image: "php:${PHP_VERSION}"
psql:
image: "postgres:${PSQL_VERSION}"
image: "postgres:${POSTGRES_VERSION}"
entrypoint: [ "psql" ]
pg_dump:
image: "postgres:${POSTGRES_VERSION}"
entrypoint: [ "pg_dump" ]
pg_dumpall:
image: "postgres:${POSTGRES_VERSION}"
entrypoint: [ "pg_dumpall" ]
protoc:
image: "protoc:${PROTOC_VERSION}"
build:
Expand Down

0 comments on commit 1df9aaa

Please sign in to comment.