Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
PORT=1234
ENV=local
PORT=8080

# local machine에서 local machine으로 접근할 때는 localhost를 사용
POSTGRES_HOST=localhost
# # local machine에서 docker container로 접근할 때는 host.docker.internal을 사용
# POSTGRES_HOST=host.docker.internal
POSTGRES_USER=example-user
POSTGRES_PASSWORD=password
POSTGRES_DB=tbh-db
POSTGRES_PORT=5432
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.DS_Store

.idea
.env
*.env
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## DB 실행

### 로컬 DB 실행
```bash
./dev-db.sh
```

### 테스트용 DB 실행
```bash
./test-db.sh
```
5 changes: 5 additions & 0 deletions deploy/postgresql/.env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
POSTGRES_USER=example-user
POSTGRES_PASSWORD=password
POSTGRES_DB=tbh-db
POSTGRES_PORT=5432
POSTGRES_CONTAINER_NAME=local-tbh-postgres
5 changes: 5 additions & 0 deletions deploy/postgresql/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
POSTGRES_USER=example-user
POSTGRES_PASSWORD=password
POSTGRES_DB=tbh-db
POSTGRES_PORT=5432
POSTGRES_CONTAINER_NAME=local-tbh-postgres
5 changes: 5 additions & 0 deletions deploy/postgresql/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
POSTGRES_USER=example-user
POSTGRES_PASSWORD=password
POSTGRES_DB=tbh-db
POSTGRES_PORT=5433
POSTGRES_CONTAINER_NAME=test-tbh-postgres
12 changes: 12 additions & 0 deletions deploy/postgresql/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: dev-tbh-postgresql
services:
postgresql:
volumes:
- dev_postgres_data:/var/lib/postgresql/data
- dev_postgres_config:/etc/postgresql/postgresql.conf

volumes:
dev_postgres_data:
name: dev_postgres_data
dev_postgres_config:
name: dev_postgres_config
12 changes: 12 additions & 0 deletions deploy/postgresql/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test-tbh-postgresql
services:
postgresql:
volumes:
- test_postgres_data:/var/lib/postgresql/data
- test_postgres_config:/etc/postgresql/postgresql.conf

volumes:
test_postgres_data:
name: test_postgres_data
test_postgres_config:
name: test_postgres_config
28 changes: 28 additions & 0 deletions deploy/postgresql/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: tbh-postgresql
services:
postgresql:
image: postgres:16
container_name: ${POSTGRES_CONTAINER_NAME}
restart: unless-stopped
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- postgres_data:/var/lib/postgresql/data
- postgres_config:/etc/postgresql/postgresql.conf
ports:
- ${POSTGRES_PORT}:5432
deploy:
resources:
limits:
cpus: "1"
memory: 512M
reservations:
memory: 256M
Comment on lines +16 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 리소스도 정해둘 수 있네요 처음알았습니다!


volumes:
postgres_data:
name: postgres_data
postgres_config:
name: postgres_config
1 change: 1 addition & 0 deletions dev-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker compose -f ./deploy/postgresql/docker-compose.yml -f ./deploy/postgresql/docker-compose.dev.yml --env-file ./deploy/postgresql/.env.dev up -d
1 change: 1 addition & 0 deletions test-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker compose -f ./deploy/postgresql/docker-compose.yml -f ./deploy/postgresql/docker-compose.test.yml --env-file ./deploy/postgresql/.env.test up -d
Loading