diff --git a/vps/Dockerfile b/vps/Dockerfile.php similarity index 100% rename from vps/Dockerfile rename to vps/Dockerfile.php diff --git a/vps/Dockerfile.postgres b/vps/Dockerfile.postgres new file mode 100644 index 0000000..45315ec --- /dev/null +++ b/vps/Dockerfile.postgres @@ -0,0 +1,26 @@ +# /home/app/Dockerfile.postgres +FROM postgres:14 + +# 安装构建工具 +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + build-essential \ + postgresql-server-dev-14 \ + git \ + ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +# 编译安装 pgvector +RUN cd /tmp && \ + git clone --branch v0.6.2 https://github.com/pgvector/pgvector.git && \ + cd pgvector && \ + make && \ + make install && \ + rm -rf /tmp/pgvector + +# 清理构建工具 +RUN apt-get purge -y --auto-remove \ + build-essential \ + postgresql-server-dev-14 \ + git && \ + rm -rf /var/cache/apt/archives \ No newline at end of file diff --git a/vps/docker-compose.yml b/vps/docker-compose.yml index 62fe838..69285c7 100644 --- a/vps/docker-compose.yml +++ b/vps/docker-compose.yml @@ -21,7 +21,7 @@ services: php: build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile.php args: PHP_VERSION: "8.2" container_name: php @@ -34,7 +34,7 @@ services: php74: build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile.php args: PHP_VERSION: "7.4" container_name: php74 @@ -80,7 +80,9 @@ services: - docker_network1 postgres: - image: postgres:14 + build: + context: . + dockerfile: Dockerfile.postgres container_name: postgresql restart: always environment: @@ -90,6 +92,7 @@ services: ports: - 9332:5432 volumes: - - ./postgresql:/var/lib/postgresql + - ./postgresql/data:/var/lib/postgresql/data + - ./postgresql/init.sql:/docker-entrypoint-initdb.d/init.sql networks: - docker_network1 diff --git a/vps/init_env.sh b/vps/init_env.sh index c2726d3..a5d57f1 100644 --- a/vps/init_env.sh +++ b/vps/init_env.sh @@ -44,10 +44,12 @@ wget -O /home/app/nginx.conf https://raw.githubusercontent.com/shakenny/containe wget -O /home/app/conf.d/default.conf https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/default.conf wget -O /home/app/mysql/conf.d/my.cnf https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/my.cnf -wget -O /home/app/mysql/conf.d/init.sql https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/vps/init.sql +wget -O /home/app/mysql/conf.d/init.sql https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/vps/init_mysql.sql wget -O /home/app/redis/conf/redis.conf https://raw.githubusercontent.com/redis/redis/7.2/redis.conf +wget -O /home/app/postgresql/init.sql https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/vps/init_postgres.sql + # 修改Redis配置文件 sed -i "s/bind 127.0.0.1 -::1/bind 0.0.0.0/g" /home/app/redis/conf/redis.conf sed -i "s/# requirepass foobared/requirepass \!Ybw324\!/g" /home/app/redis/conf/redis.conf diff --git a/vps/init.sql b/vps/init_mysql.sql similarity index 100% rename from vps/init.sql rename to vps/init_mysql.sql diff --git a/vps/init_postgres.sql b/vps/init_postgres.sql new file mode 100644 index 0000000..fa4fd87 --- /dev/null +++ b/vps/init_postgres.sql @@ -0,0 +1,2 @@ +-- 自动创建vector扩展 +CREATE EXTENSION IF NOT EXISTS vector; \ No newline at end of file