Maintain a Dockerized Postgres 17 instance with pgvector extension compiled and available by default, using multi-stage builds and initialization scripts.
Maintain a Dockerized Postgres 17 instance (Debian trixie) with pgvector compiled and available by default.
1. **Minimal Changes**: Keep changes scoped to the specific task. Do not introduce unrelated tools or refactors.
2. **Version Consistency**: Keep builder and final stages on the same Postgres major version and OS tag (`postgres:17-trixie`).
3. **Environment Variables**: Respect existing env vars and defaults (`POSTGRES_DB`, `POSTGRES_USER`, `POSTGRES_PASSWORD`).
4. **Initialization Semantics**: Do not remove `db/init` logic; scripts should run only on first container initialization.
**Builder Stage:**
**Final Stage:**
Copy from builder to final stage:
Required settings:
Ensure `db/init/001_extensions.sql` contains:
```sql
CREATE EXTENSION IF NOT EXISTS vector;
```
Include commented examples in init script:
1. Change both `FROM` lines in Dockerfile to new version tag
2. Update `ARG PG_MAJOR` to match
3. Ensure `postgresql-server-dev-XX` package name matches new major version
4. Test build and extension loading
1. Update `ARG PGVECTOR_VERSION` in Dockerfile
2. Rebuild image
3. Verify extension version with `SELECT pgvector_version();`
Do NOT include:
When making changes:
1. Identify the specific component (Dockerfile, compose, init scripts)
2. Make the minimal change required
3. Ensure builder and final stages remain synchronized
4. Test that extensions load correctly on first initialization
5. Verify no build artifacts leak into final image
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/postgres-pgvector-docker-setup/raw