Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build_images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0

- name: Setup QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0

- name: Install cosign
uses: sigstore/cosign-installer@v3
uses: sigstore/cosign-installer@7e8b541eb2e61bf99390e1afd4be13a184e9ebc5 # v3.10.1

- name: Setup Docker Buildx
run: |
make buildx-init

- name: Login to GitHub Container Registry
uses: docker/login-action@v3.4.0
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up python
uses: actions/setup-python@v5
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.x'

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/pr_test_latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
tags: ${{ steps.get-tags.outputs.tags }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.x'

Expand Down Expand Up @@ -109,12 +109,12 @@ jobs:
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version: '1.23'
go-version: '1.25'
cache-dependency-path: tests/go.sum

- name: Pull image
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ jobs:
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version: '1.23'
go-version: '1.25'
cache-dependency-path: tests/go.sum

- name: Pull image
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
.vscode
.DS_Store

# Python
__pycache__/

# Go binaries
tests/tests

2 changes: 1 addition & 1 deletion packagelists/amd64/pg16.13-spock5.0.6-standard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pgedge-lolor_16-1.2.2-1.el9
pgedge-pgaudit_16-16.1-1.el9
pgedge-postgis35_16-3.5.5-1.el9
pgedge-pgvector_16-0.8.1-1.el9
pgedge-pgbackrest-2.57.0-1.el9
pgedge-pgbackrest-2.58.0-1.el9
pgedge-python3-psycopg2-2.9.10-1.el9
pgedge-pgmq_16-1.8.0-1.el9
pgedge-pg_cron_16-1.6.7-1.el9
Expand Down
2 changes: 1 addition & 1 deletion packagelists/amd64/pg17.9-spock5.0.6-standard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pgedge-lolor_17-1.2.2-1.el9
pgedge-pgaudit_17-17.1-1.el9
pgedge-postgis35_17-3.5.5-1.el9
pgedge-pgvector_17-0.8.1-1.el9
pgedge-pgbackrest-2.57.0-1.el9
pgedge-pgbackrest-2.58.0-1.el9
pgedge-python3-psycopg2-2.9.10-1.el9
pgedge-pgmq_17-1.8.0-1.el9
pgedge-pg_cron_17-1.6.7-1.el9
Expand Down
2 changes: 1 addition & 1 deletion packagelists/amd64/pg18.3-spock5.0.6-standard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pgedge-lolor_18-1.2.2-1.el9
pgedge-pgaudit_18-18.0-1.el9
pgedge-postgis35_18-3.5.5-1.el9
pgedge-pgvector_18-0.8.1-1.el9
pgedge-pgbackrest-2.57.0-1.el9
pgedge-pgbackrest-2.58.0-1.el9
pgedge-python3-psycopg2-2.9.10-1.el9
pgedge-pgmq_18-1.8.0-1.el9
pgedge-pg_cron_18-1.6.7-1.el9
Expand Down
2 changes: 1 addition & 1 deletion packagelists/arm64/pg16.13-spock5.0.6-standard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pgedge-lolor_16-1.2.2-1.el9
pgedge-pgaudit_16-16.1-1.el9
pgedge-postgis35_16-3.5.5-1.el9
pgedge-pgvector_16-0.8.1-1.el9
pgedge-pgbackrest-2.57.0-1.el9
pgedge-pgbackrest-2.58.0-1.el9
pgedge-python3-psycopg2-2.9.10-1.el9
pgedge-pgmq_16-1.8.0-1.el9
pgedge-pg_cron_16-1.6.7-1.el9
Expand Down
2 changes: 1 addition & 1 deletion packagelists/arm64/pg17.9-spock5.0.6-standard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pgedge-lolor_17-1.2.2-1.el9
pgedge-pgaudit_17-17.1-1.el9
pgedge-postgis35_17-3.5.5-1.el9
pgedge-pgvector_17-0.8.1-1.el9
pgedge-pgbackrest-2.57.0-1.el9
pgedge-pgbackrest-2.58.0-1.el9
pgedge-python3-psycopg2-2.9.10-1.el9
pgedge-pgmq_17-1.8.0-1.el9
pgedge-pg_cron_17-1.6.7-1.el9
Expand Down
2 changes: 1 addition & 1 deletion packagelists/arm64/pg18.3-spock5.0.6-standard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pgedge-lolor_18-1.2.2-1.el9
pgedge-pgaudit_18-18.0-1.el9
pgedge-postgis35_18-3.5.5-1.el9
pgedge-pgvector_18-0.8.1-1.el9
pgedge-pgbackrest-2.57.0-1.el9
pgedge-pgbackrest-2.58.0-1.el9
pgedge-python3-psycopg2-2.9.10-1.el9
pgedge-pgmq_18-1.8.0-1.el9
pgedge-pg_cron_18-1.6.7-1.el9
Expand Down
131 changes: 56 additions & 75 deletions scripts/build_pgedge_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,23 @@ def make_all_flavor_images(
*make_all_flavor_images(
postgres_version="16.13",
spock_version="5.0.6",
epoch=1,
epoch=2,
is_latest_for_pg_major=True,
is_latest_for_spock_major=True,
),
# pg17 images
*make_all_flavor_images(
postgres_version="17.9",
spock_version="5.0.6",
epoch=1,
epoch=2,
is_latest_for_pg_major=True,
is_latest_for_spock_major=True,
),
# pg18 images
*make_all_flavor_images(
postgres_version="18.3",
spock_version="5.0.6",
epoch=1,
epoch=2,
is_latest_for_pg_major=True,
is_latest_for_spock_major=True,
),
Expand Down Expand Up @@ -252,10 +252,10 @@ def build(
if no_cache:
bake_args.append("--no-cache")
if only_arch:
bake_args.extend(("--set", f"default.platforms=linux/{only_arch}"))
bake_args.extend(("--set", f"default.platform=linux/{only_arch}"))

subprocess.check_output(
bake_cmd("--push"),
bake_cmd(*bake_args),
env={
**os.environ.copy(),
"PACKAGE_RELEASE_CHANNEL": image.package_release_channel,
Expand Down Expand Up @@ -297,6 +297,53 @@ def add_tag(repo: str, existing_tag: Tag, new_tag: Tag, dry_run: bool):
)


def _log_config(config: "Config") -> None:
if config.dry_run:
logging.info("dry run enabled. build and publish actions will be skipped.")
if config.republish:
logging.info("republish enabled. images will be republished.")
if config.no_cache:
logging.info("no cache enabled. images will be built without cache.")
if config.only_postgres_version:
logging.info(f"only postgres {config.only_postgres_version} enabled. other images will be skipped.")
if config.only_spock_version:
logging.info(f"only spock {config.only_spock_version} enabled. other images will be skipped.")
if config.only_arch:
logging.info(f"only arch {config.only_arch} enabled. builds will target linux/{config.only_arch} only.")


def _should_skip_image(image: "PgEdgeImage", config: "Config") -> bool:
if config.only_postgres_version and image.postgres_version != config.only_postgres_version:
return True
if config.only_spock_version and image.spock_version != config.only_spock_version:
return True
return False


def _process_extra_tags(config: "Config", image: "PgEdgeImage", published: set) -> None:
for tag in image.extra_tags:
tag_published = published_digests(config.repo, tag)
if config.republish or tag_published != published:
add_tag(repo=config.repo, existing_tag=image.build_tag, new_tag=tag, dry_run=config.dry_run)
else:
logging.info(f"{tag} is already up-to-date")


def _process_image(config: "Config", image: "PgEdgeImage") -> None:
published = published_digests(config.repo, image.build_tag)
if len(published) == 0 or config.republish:
build(repo=config.repo, image=image, dry_run=config.dry_run, no_cache=config.no_cache, only_arch=config.only_arch)
if not config.dry_run:
digest = index_digest(config.repo, image.build_tag)
sign(repo=config.repo, digest=digest, dry_run=config.dry_run)
published = published_digests(config.repo, image.build_tag)
else:
logging.info("dry run enabled; skipping digest lookup and signing")
else:
logging.info(f"{image.build_tag} is already published")
_process_extra_tags(config, image, published)


def main():
logging.basicConfig(
level=logging.INFO,
Expand All @@ -305,84 +352,18 @@ def main():

config = Config.from_env()

# If list_latest_tags is enabled, output tags and exit
if config.list_latest_tags:
tags = get_latest_tags()
# Output as comma-separated list
print(",".join(tags))
print(",".join(get_latest_tags()))
return

if config.dry_run:
logging.info("dry run enabled. build and publish actions will be skipped.")

if config.republish:
logging.info("republish enabled. images will be republished.")

if config.no_cache:
logging.info("no cache enabled. images will be built without cache.")

if config.only_postgres_version:
logging.info(
f"only postgres {config.only_postgres_version} enabled. other images will be skipped."
)

if config.only_spock_version:
logging.info(
f"only spock {config.only_spock_version} enabled. other images will be skipped."
)

if config.only_arch:
logging.info(
f"only arch {config.only_arch} enabled. other images will be skipped."
)

_log_config(config)
validate_images(all_images)

for image in all_images:
if (
config.only_postgres_version
and image.postgres_version != config.only_postgres_version
) or (
config.only_spock_version
and image.spock_version != config.only_spock_version
):
if _should_skip_image(image, config):
logging.info(f"skipping image {image.build_tag}")
continue

published = published_digests(config.repo, image.build_tag)
if len(published) == 0 or config.republish:
build(
repo=config.repo,
image=image,
dry_run=config.dry_run,
no_cache=config.no_cache,
only_arch=config.only_arch,
)

id = index_digest(config.repo, image.build_tag)
sign(
repo=config.repo,
digest=id,
dry_run=config.dry_run,
)
else:
logging.info(f"{image.build_tag} is already published")

for tag in image.extra_tags:
tag_published = published_digests(config.repo, tag)
if (
len(tag_published) == 0
or not tag_published.issubset(published)
or config.republish
):
add_tag(
repo=config.repo,
existing_tag=image.build_tag,
new_tag=tag,
dry_run=config.dry_run,
)
else:
logging.info(f"{tag} is already up-to-date")
_process_image(config, image)


def get_latest_tags() -> list[str]:
Expand Down
18 changes: 10 additions & 8 deletions tests/go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module github.com/pgedge/postgres-images/tests

go 1.24.11
go 1.25.8

require github.com/docker/docker v28.0.0+incompatible

require (
github.com/Microsoft/go-winio v0.4.14 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
Expand All @@ -20,13 +21,14 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
go.opentelemetry.io/otel v1.40.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.40.0 // indirect
go.opentelemetry.io/otel/metric v1.40.0 // indirect
go.opentelemetry.io/otel/sdk v1.40.0 // indirect
go.opentelemetry.io/otel/trace v1.40.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/time v0.14.0 // indirect
gotest.tools/v3 v3.5.1 // indirect
)
Loading
Loading