refactor(docker): 重构本地开发环境配置

将通用Dockerfile重命名为Dockerfile.php以明确用途
添加PostgreSQL自定义镜像配置以支持pgvector扩展
拆分数据库初始化脚本为mysql和postgres专用版本
更新docker-compose配置以使用新的构建文件
This commit is contained in:
Kenny Yang committed 2025-05-29 01:43:17 +08:00
1 parent 41a1e57855
commit 4c9e71955e
6 files changed
+38 -5

No files matched your search

File renamed without changes.
+26
View File
@@ -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
+7 -4
View File
@@ -32,7 +32,7 @@ services:
php: php:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile.php
args: args:
PHP_VERSION: "8.2" PHP_VERSION: "8.2"
container_name: php container_name: php
@@ -45,7 +45,7 @@ services:
php74: php74:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile.php
args: args:
PHP_VERSION: "7.4" PHP_VERSION: "7.4"
container_name: php74 container_name: php74
@@ -91,7 +91,9 @@ services:
- docker_network1 - docker_network1
postgres: postgres:
image: postgres:14 build:
context: .
dockerfile: Dockerfile.postgres
container_name: postgresql container_name: postgresql
restart: always restart: always
environment: environment:
@@ -101,6 +103,7 @@ services:
ports: ports:
- "5432:5432" - "5432:5432"
volumes: volumes:
- ./postgresql:/var/lib/postgresql - ./postgresql/data:/var/lib/postgresql/data
- ./postgresql/init.sql:/docker-entrypoint-initdb.d/init.sql
networks: networks:
- docker_network1 - docker_network1
+3 -1
View File
@@ -66,10 +66,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/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/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/local/init.sql wget -O /home/app/mysql/conf.d/init.sql https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/local/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/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/local/init_postgres.sql
# 修改Redis配置文件 # 修改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/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 sed -i "s/# requirepass foobared/requirepass \!Ybw324\!/g" /home/app/redis/conf/redis.conf
File renamed without changes.
+2
View File
@@ -0,0 +1,2 @@
-- 自动创建vector扩展
CREATE EXTENSION IF NOT EXISTS vector;