Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 7 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ CLICKHOUSE_DATABASE=default
# ORACLE_DATABASE=_
# ORACLE_SERVICE_NAME=_

# postgres
# DB_TYPE=postgres
# POSTGRES_HOST=_
# POSTGRES_PORT=5432
# POSTGRES_USER=_
# POSTGRES_PASSWORD=_
# POSTGRES_DATABASE=_
# postgresql
# DB_TYPE=postgresql
# POSTGRESQL_HOST=_
# POSTGRESQL_PORT=5432
# POSTGRESQL_USER=_
# POSTGRESQL_PASSWORD=_
# POSTGRESQL_DATABASE=_

# snowflake
# DB_TYPE=snowflake
Expand Down
23 changes: 23 additions & 0 deletions docker/docker-compose-postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# docker compose -f docker-compose-postgres.yml up
# docker compose -f docker-compose-postgres.yml down

services:
postgres:
image: postgres:15
hostname: postgres
container_name: postgres
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: rootpassword
POSTGRES_DB: postgres
TZ: Asia/Seoul
LANG: en_US.utf8
volumes:
- postgres_data:/var/lib/postgresql/data
- ./postgres/init:/docker-entrypoint-initdb.d/init.sql
Copy link
Collaborator

Choose a reason for hiding this comment

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

docker compose -f docker-compose-postgres.yml up 명령어로 실행했을때 init.sql 이 적용되지 않는것으로 확인됩니다.

실행하면 psql:/docker-entrypoint-initdb.d/init.sql: error: could not read from input file: Is a directory 이런 로그가 출력되는데

- ./postgres/init:/docker-entrypoint-initdb.d 이렇게 수정되어야 하지않을까 생각이 듭니다아!

  • 아래 명령어로 실제 lang2sql 데이터베이스가 생성되지 않았음을 확인했습니다.
docker exec -it postgres bash
psql -U root -d postgres
\l

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ehddnr301
수정 후 아래 방법으로 수정 확인했습니다~! 감사합니다!

# 1. 기존 볼륨 삭제
docker volume rm docker_postgres_data

# 2. 도커 컴포즈 실행
docker compose -f docker-compose-postgres.yml up

# 3. 데이터베이스 확인
docker exec -it postgres psql -U postgres -l

   Name    |  Owner   | Encoding |  Collate   |   Ctype    | ICU Locale | Locale Provider |   Access privileges
-----------+----------+----------+------------+------------+------------+-----------------+-----------------------
 lang2sql  | postgres | UTF8     | en_US.utf8 | en_US.utf8 |            | libc            | =Tc/postgres         +
           |          |          |            |            |            |                 | postgres=CTc/postgres+
           |          |          |            |            |            |                 | lang2sql=CTc/postgres
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 |            | libc            |
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 |            | libc            | =c/postgres          +
           |          |          |            |            |            |                 | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 |            | libc            | =c/postgres          +
           |          |          |            |            |            |                 | postgres=CTc/postgres
 test      | postgres | UTF8     | en_US.utf8 | en_US.utf8 |            | libc            | =Tc/postgres         +
           |          |          |            |            |            |                 | postgres=CTc/postgres+
           |          |          |            |            |            |                 | test=CTc/postgres


volumes:
postgres_data:
2 changes: 2 additions & 0 deletions docker/postgres/init/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE DATABASE lang2sql;
CREATE USER lang2sql WITH PASSWORD 'lang2sqlpassword';