Skip to content

Commit 693dced

Browse files
Migrate from Docker volume mount to named volume
More info, see https://notes.sklein.xyz/2024-12-09_1550/zen/
1 parent ccdcddc commit 693dced

File tree

6 files changed

+27
-8
lines changed

6 files changed

+27
-8
lines changed

demo/.envrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export PROJECT_NAME="demo_restic_pg_dump"
2+
export INSTANCE_ID=$(pwd | shasum -a 1 | awk '{print $1}' | cut -c 1-12) # Used to define docker volume path
3+
export COMPOSE_PROJECT_NAME=${PROJECT_NAME}_${INSTANCE_ID}
4+
5+
export AWS_ACCESS_KEY_ID=admin
6+
export AWS_SECRET_ACCESS_KEY=password

demo/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
volumes/
2-
backup/
1+
backup/

demo/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# How to use stephaneklein/restic-pg_dump Docker Image
22

33
```
4+
$ source .envrc
45
$ docker compose build # optional, only used for development activities
56
$ ./scripts/up.sh
67
```
@@ -23,7 +24,7 @@ Read the ["Installation" section](https://restic.readthedocs.io/en/stable/020_in
2324
Load secret environment variables:
2425

2526
```
26-
$ source source.env
27+
$ source .envrc
2728
```
2829

2930
Here's how to display the snapshot list:
@@ -115,3 +116,9 @@ postgres=# select * from contacts limit 2;
115116
116117
```
117118

119+
120+
## Teardown
121+
122+
```sh
123+
$ docker compose down -v
124+
```

demo/docker-compose.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ services:
2222
ports:
2323
- "5432:5432"
2424
volumes:
25-
- ./volumes/postgres/:/var/lib/postgresql/data/
25+
- postgres:/var/lib/postgresql/data/
2626
healthcheck:
2727
test: ["CMD", "sh", "-c", "pg_isready -U $$POSTGRES_USER -h $$(hostname -i)"]
2828
interval: 10s
@@ -37,7 +37,7 @@ services:
3737
ports:
3838
- "5433:5432"
3939
volumes:
40-
- ./volumes/postgres-test-restore/:/var/lib/postgresql/data/
40+
- postgres-test-restore:/var/lib/postgresql/data/
4141
healthcheck:
4242
test: ["CMD", "sh", "-c", "pg_isready -U $$POSTGRES_USER -h $$(hostname -i)"]
4343
interval: 10s
@@ -52,11 +52,19 @@ services:
5252
- "9000:9000"
5353
- "9001:9001"
5454
volumes:
55-
- ./volumes/minio/:/data
55+
- minio:/data
5656
command: server /data --console-address ":9001"
5757
healthcheck:
5858
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
5959
interval: 5s
6060
timeout: 10s
6161
retries: 3
6262
start_period: 10s
63+
64+
volumes:
65+
postgres:
66+
name: ${COMPOSE_PROJECT_NAME}_postgres
67+
postgres-restore-test:
68+
name: ${COMPOSE_PROJECT_NAME}_postgres
69+
minio:
70+
name: ${COMPOSE_PROJECT_NAME}_minio

demo/scripts/up.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -e
33

44
cd "$(dirname "$0")/../"
55

6+
source .envrc
67
docker compose up -d postgres minio --wait
78

89
./scripts/import-demo-to-postgresql.sh

demo/source.env

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)