Puzzly / Puzzly-Back

BackEnd For Puzzly
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Docker Compose File, Dockerfile #57

Open hkglh12 opened 2 weeks ago

hkglh12 commented 2 weeks ago

스크린샷 2024-06-13 오후 12 09 52

Dockerfile

FROM postgres:16.3
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime && \
    sed -i 's/# ko_KR.UTF-8 UTF-8/ko_KR.UTF-8 UTF-8/' /etc/locale.gen && \
    locale-gen
ENV LANG=ko_KR.utf8\
    LC_COLLATE="C"\
    POSTGRES_INITDB_ARGS=--data-checksums

Dockerfile build

docker build -t postgres-ko:16.3 .

docker-compose.yml

version: "2"
services:
  puzzly-7220-postgresql:
    container_name: puzzly-7220-postgresql
    image: postgres-ko:16.3
    command: -c "max_connections=100"
    stdin_open: true
    tty: true
    ports:
      - "7220:5432"
    volumes:
      - ./data:/var/lib/postgresql/data
      - /logs/7220-postgresql:/var/log/postgresql
    environment:
      # AUTH Configure
      POSTGRES_PASSWORD: 
      POSTGRES_USER: puzzly
      POSTGRES_DB: puzzly
      LANG: ko_KR.utf8
      LC_MESSAGES: en_US.utf8
      # POSTGRESQL INITDB ARGS
      # collate, ctype C 아니면 인덱스 안탄다는 소문이 있음
      # SEE https://postgresql.kr/blog/collate_for_pg.html
      #POSTGRES_INITDB_ARGS: '--encoding=UTF-8 --lc-collate=C --lc-ctype=C --locale=ko_KR.UTF-8 --lc-messages=en_US.utf8'
      POSTGRES_INITDB_ARGS: '--encoding=UTF-8 --lc-collate=C --lc-ctype=C'
      TZ: "Asia/Seoul"
crimsorry commented 2 weeks ago

docker-compose.yml 아래처럼 작성하면 Dockerfile build 도 한번에 가능합니다!


version: "2"
services:
  puzzly-7220-postgresql:
    container_name: puzzly-7220-postgresql
    image: postgres-ko:16.3
    build:
      context: ./
crimsorry commented 2 weeks ago

Redis

redis.conf > RDB 방식

# Save the DB on disk:
#   900초(15분) 후에 최소 1개의 키가 변경되면 저장.
#   300초(5분) 후에 최소 10개의 키가 변경되면 저장.
#   60초 후에 최소 10000개의 키가 변경되면 저장.
save 900 1
save 300 10
save 60 10000

# DB 덤프 파일 명
dbfilename dump.rdb

# 덤프 파일을 저장할 디렉토리
dir /data

# RDB 저장 실패시 데이터 읽기 여부
stop-writes-on-bgsave-error yes

# dump.rdb LZF 알고리즘 으로 압축
rdbcompression yes

# 비밀번호 노션 참고
requirepass 

Dockerfile

FROM redis:7.2.5
ENV TZ=Asia/Seoul
COPY redis.conf /usr/local/etc/redis/redis.conf
CMD ["redis-server", "/usr/local/etc/redis/redis.conf"]

docker-compose.yml

version: '3.8'

services:
  redis:
    container_name: redis
    image: redis:7.2.5
    build:
      ./
    ports:
      - "7230:6379"
    volumes:
      - ./redis-data:/data
      - ./redis.conf:/usr/local/etc/redis/redis.conf
    environment:
      TZ: "Asia/Seoul"

volumes:
  redis-data:
    driver: local

docker build

docker compose up -d