Skip to content

Commit 550587e

Browse files
committed
chore: developer setup
Signed-off-by: Jason C. Leach <[email protected]>
1 parent 4401eb9 commit 550587e

File tree

3 files changed

+111
-1
lines changed

3 files changed

+111
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ settings*.sh
1414

1515
# Local config
1616
.env
17+
docker/backup.conf
1718
backups
18-
docker/backup.conf
19+
minio-data
20+
pg-data

DEVELOPER.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
## Docker
2+
3+
This project contains a docker-compose.yml file suitable for development purposes. It will start a PostgreSQL database, minio (S3 compatible storage) and a backup container.
4+
5+
Because all the bash scripts are mounted to root `/` the docker-compose file mounts them all individually. If you wish to add new files, create it then add it to the backup container mounts.
6+
7+
To start the containers run:
8+
9+
```bash
10+
docker-compose up
11+
```
12+
13+
Once all 3 containers start they will create three folders that are **not** tracked by git:
14+
15+
- `./pg-data` - PostgreSQL database
16+
- `./minio-data` - Minio storage
17+
- `./backup` - Backup data
18+
19+
Add this shell (bash or zsh) alias, it helps to quickly connect to a container by name:
20+
21+
```bash
22+
dcon='function _dcon(){ docker exec -i -t $1 /bin/bash -c "export COLUMNS=`tput cols`; export LINES=`tput lines`; exec bash"; };_dcon'
23+
```
24+
25+
Use `docker ps` to list all running containers and then use `dcon <container_name>` to connect to the container.
26+
27+
```bash
28+
dcon backup-container-postgresql-1
29+
```
30+
31+
### Protips 🤓
32+
33+
- More modern version fo docker-compose do not require the hyphen. Try using `docker compose up`.
34+
- This bash one-liner was used to add all the files to the backup container volumes `ls docker/ | grep 'backup\.' | awk '{ print "- ./docker/"$1":/"$1 }'`
35+
36+
## Postgres
37+
38+
Connect to the postgres container using the `dcon` alias noted above and create the database, schema and then load in some sample data.
39+
40+
Connect to the postgres container:
41+
42+
```bash
43+
dcon backup-container-postgresql-1
44+
```
45+
46+
Run the `psql` command to connect to the database and create the database:
47+
48+
```bash
49+
psql -U postgres
50+
create database sakila;
51+
^D
52+
```
53+
54+
Run the following two commands to create the schema and insert the data. If `curl` is not installed run `apt-get update && apt-get install curl` first.
55+
56+
```bash
57+
curl -sSL https://raw.githubusercontent.com/jOOQ/sakila/main/postgres-sakila-db/postgres-sakila-schema.sql | psql -U postgres -d sakila;
58+
```
59+
60+
```bash
61+
curl -sSL https://raw.githubusercontent.com/jOOQ/sakila/main/postgres-sakila-db/postgres-sakila-insert-data.sql | psql -U postgres -d sakila;
62+
```
63+
64+
You should now have a sample database with data.

docker-compose.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
version: '3.8'
2+
services:
3+
minio:
4+
image: minio/minio
5+
volumes:
6+
- ./minio-data:/data
7+
ports:
8+
- 9000:9000
9+
environment:
10+
MINIO_ROOT_USER: minio
11+
MINIO_ROOT_PASSWORD: minio123
12+
command: server /data
13+
14+
postgresql:
15+
image: postgres:12
16+
volumes:
17+
- ./pg-data:/var/lib/postgresql/data
18+
ports:
19+
- 5432:5432
20+
environment:
21+
POSTGRES_USER: postgres
22+
POSTGRES_PASSWORD: secret
23+
24+
backup:
25+
build: ./docker
26+
volumes:
27+
- ./backups:/backups
28+
- ./docker/backup.config.utils:/backup.config.utils
29+
- ./docker/backup.container.utils:/backup.container.utils
30+
- ./docker/backup.file.utils:/backup.file.utils
31+
- ./docker/backup.ftp:/backup.ftp
32+
- ./docker/backup.logging:/backup.logging
33+
- ./docker/backup.mariadb.plugin:/backup.mariadb.plugin
34+
- ./docker/backup.misc.utils:/backup.misc.utils
35+
- ./docker/backup.mongo.plugin:/backup.mongo.plugin
36+
- ./docker/backup.mssql.plugin:/backup.mssql.plugin
37+
- ./docker/backup.null.plugin:/backup.null.plugin
38+
- ./docker/backup.postgres.plugin:/backup.postgres.plugin
39+
- ./docker/backup.server.utils:/backup.server.utils
40+
- ./docker/backup.settings:/backup.settings
41+
- ./docker/backup.sh:/backup.sh
42+
- ./docker/backup.usage:/backup.usage
43+
- ./docker/backup.utils:/backup.utils
44+

0 commit comments

Comments
 (0)