From 9b354790c36daeb0b3619fb450ee4fd230ab31f1 Mon Sep 17 00:00:00 2001 From: naskya Date: Sun, 31 Mar 2024 12:13:55 +0900 Subject: [PATCH] dev: keep db/redis data on db.down --- Makefile | 6 +++--- dev/db-container/Makefile | 6 ++++-- dev/db-container/docker-compose.yml | 9 +++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 37dc019648..23d2f27ad9 100644 --- a/Makefile +++ b/Makefile @@ -27,13 +27,13 @@ build: pnpm run migrate -.PHONY: db.init db.up db.down -db.init: - $(MAKE) -C ./dev/db-container init +.PHONY: db.up db.down db.init db.up: $(MAKE) -C ./dev/db-container up db.down: $(MAKE) -C ./dev/db-container down +db.init: + $(MAKE) -C ./dev/db-container init .PHONY: psql redis-cli psql: diff --git a/dev/db-container/Makefile b/dev/db-container/Makefile index 0238308de4..a762e95110 100644 --- a/dev/db-container/Makefile +++ b/dev/db-container/Makefile @@ -1,9 +1,11 @@ -.PHONY: init up down -init: down up +.PHONY: up down init up: $(COMPOSE) up --detach down: $(COMPOSE) down +init: + $(COMPOSE) down --volumes + $(COMPOSE) up --detach .PHONY: psql redis-cli psql: diff --git a/dev/db-container/docker-compose.yml b/dev/db-container/docker-compose.yml index 4cd121d2d4..770d8fb18d 100644 --- a/dev/db-container/docker-compose.yml +++ b/dev/db-container/docker-compose.yml @@ -5,6 +5,8 @@ services: image: docker.io/redis:7-alpine ports: - "26379:6379" + volumes: + - "redis-data:/data" db: image: docker.io/groonga/pgroonga:3.1.8-alpine-12 env_file: @@ -13,3 +15,10 @@ services: - "25432:5432" volumes: - "./install.sql:/docker-entrypoint-initdb.d/install.sql:ro" + - "postgres-data:/var/lib/postgresql/data" + +volumes: + redis-data: + name: redis-data + postgres-data: + name: postgres-data