diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 0e7d6af3..7005c749 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -13,44 +13,6 @@ permissions: contents: read jobs: - build-postgres: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Checkout - uses: actions/checkout@v6 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v4 - - - name: Log in to GHCR - uses: docker/login-action@v4 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Derive postgres image name - id: postgres-image - shell: bash - run: echo "name=${GITHUB_REPOSITORY_OWNER,,}/mailsangja-postgres" >> "$GITHUB_OUTPUT" - - - name: Build and push postgres image - uses: docker/build-push-action@v7 - with: - context: . - file: docker/postgres/Dockerfile - push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ env.REGISTRY }}/${{ steps.postgres-image.outputs.name }}:sha-${{ github.sha }} - cache-from: type=gha,scope=postgres - cache-to: type=gha,scope=postgres,mode=max - build: runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/build-postgres-image.yml b/.github/workflows/build-postgres-image.yml new file mode 100644 index 00000000..1d3cdccb --- /dev/null +++ b/.github/workflows/build-postgres-image.yml @@ -0,0 +1,55 @@ +name: Build Postgres Docker Image + +on: + push: + branches: + - main + paths: + - docker/postgres/Dockerfile + - .github/workflows/build-postgres-image.yml + workflow_dispatch: + +env: + REGISTRY: ghcr.io + +permissions: + contents: read + +jobs: + build-postgres: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Log in to GHCR + uses: docker/login-action@v4 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Derive postgres image name + id: postgres-image + shell: bash + run: echo "name=${GITHUB_REPOSITORY_OWNER,,}/mailsangja-postgres" >> "$GITHUB_OUTPUT" + + - name: Build and push postgres image + uses: docker/build-push-action@v7 + with: + context: . + file: docker/postgres/Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ env.REGISTRY }}/${{ steps.postgres-image.outputs.name }}:sha-${{ github.sha }} + cache-from: type=gha,scope=postgres + cache-to: type=gha,scope=postgres,mode=max diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index 58faf968..7988b0b9 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -69,9 +69,15 @@ jobs: source_commit_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${source_sha}" fi + display_tag="$image_tag" + if [[ "$image_tag" == sha-* ]]; then + display_tag="${image_tag:4:7}" + fi + { echo "should_update=${should_update}" echo "image_tag=${image_tag}" + echo "display_tag=${display_tag}" echo "source_sha=${source_sha}" echo "source_commit_url=${source_commit_url}" echo "workflow_run_url=${workflow_run_url}" @@ -117,8 +123,8 @@ jobs: branch: automation/mailsangja base: main delete-branch: true - commit-message: "release: 메일상자 이미지 업데이트 (${{ steps.meta.outputs.image_tag }})" - title: "release: 메일상자 이미지 업데이트 (${{ steps.meta.outputs.image_tag }})" + commit-message: "release: 메일상자 업데이트 (${{ steps.meta.outputs.display_tag }})" + title: "release: 메일상자 업데이트 (${{ steps.meta.outputs.display_tag }})" body: | Automated image tag update from `mailsangja-server`. @@ -133,7 +139,6 @@ jobs: - `apps/mailsangja/core.yaml` - `apps/mailsangja/worker.yaml` - `apps/mailsangja/postgres.yaml` is intentionally unchanged. Merge this PR to let Argo CD sync the new application images. add-paths: | apps/mailsangja/core.yaml diff --git a/compose.yaml b/compose.yaml index 2a479049..c9a59108 100644 --- a/compose.yaml +++ b/compose.yaml @@ -14,7 +14,7 @@ services: - "${DB_PORT:-5432}:5432" volumes: - postgres_data:/var/lib/postgresql - - ./db/src/main/resources/extensions.sql:/docker-entrypoint-initdb.d/00-extensions.sql:ro + - ./docker/postgres/init/00-extensions.sql:/docker-entrypoint-initdb.d/00-extensions.sql:ro healthcheck: test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME:-mailsangja}"] interval: 10s diff --git a/db/src/main/resources/init.sql b/db/src/main/resources/init.sql index 6494e002..641677eb 100644 --- a/db/src/main/resources/init.sql +++ b/db/src/main/resources/init.sql @@ -226,7 +226,7 @@ CREATE INDEX IF NOT EXISTS idx_threads_last_message_at ON threads(last_message_a -- WHERE filename_vector IS NULL; -- ── Full-Text Search (English, pg_trgm) ────────────────────────────────────── --- pg_trgm 확장은 extensions.sql(docker-entrypoint-initdb.d)에서 superuser로 설치됨 +-- pg_trgm 확장은 docker/postgres/init/00-extensions.sql(docker-entrypoint-initdb.d)에서 superuser로 설치됨 -- messages.search_text: 영어 부분/대소문자 무시 검색을 위한 소문자 정규화 텍스트 -- body_text는 인덱스 크기 제한을 위해 앞 5000자만 포함 diff --git a/docker/observability/loki/loki.yaml b/docker/observability/loki/loki.yaml index ef2ece56..3e1f800b 100644 --- a/docker/observability/loki/loki.yaml +++ b/docker/observability/loki/loki.yaml @@ -26,6 +26,16 @@ storage_config: limits_config: allow_structured_metadata: true + retention_period: 336h + max_query_lookback: 336h + +compactor: + working_directory: /loki/compactor + compaction_interval: 10m + retention_enabled: true + retention_delete_delay: 2h + retention_delete_worker_count: 50 + delete_request_store: filesystem analytics: reporting_enabled: false diff --git a/db/src/main/resources/extensions.sql b/docker/postgres/init/00-extensions.sql similarity index 100% rename from db/src/main/resources/extensions.sql rename to docker/postgres/init/00-extensions.sql