Build scripts for creating PostgreSQL virtual machine images from Ubuntu cloud images. Supports multiple architectures (x64/arm64) and build flavors.
# Build standard image (8GB disk)
sudo ./build.sh standard
# Build with custom disk size
sudo ./build.sh standard 16
# Build ParadeDB flavor
sudo ./build.sh paradedb| Flavor | Description |
|---|---|
standard |
PostgreSQL with common extensions, CloudWatch agent, ClamAV scanning |
paradedb |
Standard + ParadeDB extensions (pg_analytics, pg_search) |
- PostgreSQL: Versions 16, 17, and 18 (packages cached, not installed)
- Extensions: pg_cron, pgvector, postgis-3, pgaudit, pglogical, pgrouting, pgtap, hypopg, pg_repack, partman, h3, hll, mysql-fdw, tds-fdw, orafce, similarity, pguint
- WAL-G: Built from source for backup/restore
- pgbouncer: Connection pooling
- Prometheus v2.53.0
- Node Exporter v1.8.1
- Postgres Exporter v0.15.0
- Data checksums enabled by default
- Auto-cluster creation disabled
- Custom
createcluster.ddirectory support
- Linux host (Ubuntu/Debian recommended)
- Root/sudo access
- Required packages:
qemu-utils,kpartx,parted,guestfs-tools - Minimum 8GB free disk space
The build script auto-detects the host architecture:
- x86_64 → builds
postgres-<flavor>-x64-image.raw - aarch64 → builds
postgres-<flavor>-arm64-image.raw
postgres-vm-images/
├── build.sh # Main build script
├── common/ # Shared setup scripts
│ ├── setup_base.sh # PostgreSQL repos, users, package caching
│ ├── setup_packages.sh # WAL-G and pguint compilation
│ ├── setup_monitoring.sh # Prometheus stack installation
│ ├── setup_cleanup.sh # Cloud-init and system cleanup
│ └── assets/ # Service files and package lists
│ ├── packages/ # PostgreSQL package lists (16.txt, 17.txt, etc.)
│ ├── prometheus.service
│ ├── node_exporter.service
│ ├── postgres_exporter.service
│ └── wal-g.service
├── flavors/ # Flavor-specific configurations
│ ├── standard/
│ │ └── setup.sh # CloudWatch agent, ClamAV
│ └── paradedb/
│ ├── setup.sh # ParadeDB extensions
│ └── config.sh # Version configuration
└── .github/workflows/ # CI/CD pipelines
- Downloads Ubuntu 22.04 (Jammy) cloud image for the detected architecture
- Resizes disk image to specified size using
virt-resize - Mounts image via loop device and chroot (native speed, no QEMU emulation)
- Runs setup scripts:
setup_base.sh: PostgreSQL repository, users/groups, package cachingsetup_packages.sh: Builds WAL-G and pguint from sourcesetup_monitoring.sh: Installs Prometheus monitoring stackflavors/<flavor>/setup.sh: Flavor-specific setupsetup_cleanup.sh: Cloud-init cleanup, service configuration
- Cleans up: removes SSH host keys, clears machine-id, zeros free space
- Outputs raw disk image
Services are installed but not enabled by default:
systemctl enable --now prometheus
systemctl enable --now node_exporter
systemctl enable --now postgres_exporter| User/Group | Purpose |
|---|---|
prometheus |
Runs Prometheus and Node Exporter |
ubi_monitoring |
Runs Postgres Exporter |
cert_readers |
Certificate access (includes postgres, prometheus) |
- PostgreSQL packages are cached but not installed. Install specific versions on first boot.
- SSH host keys are removed during build and regenerated on first boot.
- Cloud-init is cleaned for proper re-initialization.
- Machine-id is cleared for cloud deployment compatibility.
The repository includes CI/CD workflows for:
- Building images on x64 and arm64 runners
- Uploading to AWS AMI and Cloudflare R2
- Cleanup of old images and AMIs
MIT License - see LICENSE for details.