diff --git a/.github/workflows/pg-image-build.yml b/.github/workflows/pg-image-build.yml
new file mode 100644
index 0000000..46cbf9a
--- /dev/null
+++ b/.github/workflows/pg-image-build.yml
@@ -0,0 +1,112 @@
+name: Build the Postgres image
+
+on:
+ workflow_dispatch
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+env:
+ REGISTRY: ghcr.io
+ IMAGE_NAME: ${{ github.repository }}/cvsa-pg
+
+jobs:
+ build:
+ runs-on: ${{ matrix.runner }}
+ permissions:
+ packages: write
+
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - arch: amd64
+ platform: linux/amd64
+ runner: ubuntu-latest
+ - arch: arm64
+ platform: linux/arm64
+ runner: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Docker meta
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+ flavor: |
+ suffix=-${{ matrix.arch }},onlatest=true
+ tags: |
+ type=raw,value=latest,enable={{is_default_branch}}
+
+ - name: Login GHCR
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+ with:
+ driver-opts: |
+ image=moby/buildkit:latest
+ network=host
+
+ - name: Build & Push single platform
+ id: build
+ uses: docker/build-push-action@v6
+ with:
+ context: .
+ file: ./Dockerfile.pg
+ platforms: ${{ matrix.platform }}
+ push: true
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+ outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Export digest
+ run: echo "${{ steps.build.outputs.digest }}" > /tmp/digest-${{ matrix.arch }}
+
+ - name: Upload digest artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: digest-${{ matrix.arch }}
+ path: /tmp/digest-${{ matrix.arch }}
+ if-no-files-found: error
+
+ create-manifest:
+ needs: build
+ if: github.event_name != 'pull_request'
+ runs-on: ubuntu-latest
+ permissions:
+ packages: write
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Login GHCR
+ uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Download all digests
+ uses: actions/download-artifact@v4
+ with:
+ pattern: digest-*
+ path: digests
+ merge-multiple: true
+
+ - name: Create multi-arch manifest
+ run: |
+ docker buildx imagetools create \
+ --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
+ --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
+ $(cat digests/digest-amd64) \
+ $(cat digests/digest-arm64)
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index f582f85..d609266 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,7 +35,7 @@ __pycache__
/data
/redis
-# Build
+# Build
dist/
build/
@@ -47,4 +47,6 @@ mutagen.yml
mutagen.yml.lock
-.turbo
\ No newline at end of file
+.turbo
+
+docker-compose.yml
diff --git a/.idea/.gitignore b/.idea/.gitignore
index d0e22e9..87ccf09 100644
--- a/.idea/.gitignore
+++ b/.idea/.gitignore
@@ -7,4 +7,5 @@
/dataSources/
/dataSources.local.xml
dataSources.xml
-MarsCodeWorkspaceAppSettings.xml
\ No newline at end of file
+MarsCodeWorkspaceAppSettings.xml
+data_source_mapping.xml
\ No newline at end of file
diff --git a/.idea/data_source_mapping.xml b/.idea/data_source_mapping.xml
index 90c8c3b..16bd6fb 100644
--- a/.idea/data_source_mapping.xml
+++ b/.idea/data_source_mapping.xml
@@ -9,17 +9,7 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Dockerfile.pg b/Dockerfile.pg
new file mode 100644
index 0000000..d236b21
--- /dev/null
+++ b/Dockerfile.pg
@@ -0,0 +1,65 @@
+FROM postgres:18.1
+
+RUN localedef -i zh_CN -c -f UTF-8 -A /usr/share/locale/locale.alias zh_CN.UTF-8
+ENV LANG=zh_CN.utf8 LC_ALL=zh_CN.utf8
+
+LABEL maintainer="alikia2x " \
+ description="Customized PostgreSQL image for Project CVSA including TimescaleDB & pgBackRest" \
+ version="1.0.0" \
+ org.opencontainers.image.title="CVSA PostgreSQL Extended" \
+ org.opencontainers.image.description="Customized PostgreSQL image for Project CVSA including TimescaleDB & pgBackRest" \
+ org.opencontainers.image.vendor="Luminara Studio" \
+ org.opencontainers.image.version="1.0.0" \
+ org.opencontainers.image.authors="alikia2x@outlook.com"
+
+ENV DEBIAN_FRONTEND=noninteractive \
+ TZ=Asia/Shanghai
+
+USER root
+
+RUN set -eux; \
+ apt update -qq; \
+ apt install -y --no-install-recommends \
+ ca-certificates \
+ curl \
+ gnupg \
+ lsb-release \
+ wget \
+ ; \
+ curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg; \
+ echo "deb https://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list; \
+ \
+ curl -L https://packagecloud.io/timescale/timescaledb/gpgkey | gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg; \
+ echo "deb https://packagecloud.io/timescale/timescaledb/debian/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/timescaledb.list; \
+ \
+ wget https://packages.groonga.org/debian/groonga-apt-source-latest-$(lsb_release --codename --short).deb; \
+ apt install -y -V ./groonga-apt-source-latest-$(lsb_release --codename --short).deb; \
+ \
+ apt update -q;
+
+RUN apt install -y -V \
+ timescaledb-2-postgresql-18 \
+ postgresql-18-pgvector \
+ postgresql-18-cron \
+ postgresql-18-repack \
+ pgbackrest \
+ ;
+
+RUN apt purge -y --auto-remove \
+ curl gnupg lsb-release wget \
+ && apt clean \
+ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+
+RUN mkdir -p /etc/postgresql/custom
+RUN cp /usr/share/postgresql/postgresql.conf.sample /etc/postgresql/postgresql.conf
+RUN echo "include_dir = '/etc/postgresql/custom/'" >> /etc/postgresql/postgresql.conf
+RUN echo "shared_preload_libraries = 'timescaledb,pg_cron,pg_stat_statements'" >> /etc/postgresql/custom/extensions.conf
+
+USER postgres
+
+EXPOSE 5432
+
+HEALTHCHECK --interval=20s --timeout=10s --start-period=5s --retries=3 \
+ CMD pg_isready -U postgres -h 127.0.0.1 || exit 1
+
+CMD ["postgres"]
\ No newline at end of file