Skip to content

Commit

Permalink
Make it easy to build only a subset of extensions into compute image (#…
Browse files Browse the repository at this point in the history
…10655)

The full build of all extensions takes a long time. When working locally
on parts that don't need extensions, you can iterate more quickly by
skipping the unnecessary extensions.

This adds a build argument to the dockerfile to specify extensions to
build. There are three options:

- EXTENSIONS=all (default)
- EXTENSIONS=minimal: Build only a few extensions that are listed in
shared_preload_libraries in the default neon config.
- EXTENSIONS=none: Build no extensions (except for the mandatory 'neon'
extension).
  • Loading branch information
hlinnaka authored Feb 5, 2025
1 parent 133b89a commit 6699a30
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions compute/compute-node.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ ARG DEBIAN_VERSION=bookworm
ARG DEBIAN_FLAVOR=${DEBIAN_VERSION}-slim
ARG ALPINE_CURL_VERSION=8.11.1

# By default, build all PostgreSQL extensions. For quick local testing when you don't
# care about the extensions, pass EXTENSIONS=none or EXTENSIONS=minimal
ARG EXTENSIONS=all

#########################################################################################
#
# Layer "build-deps"
Expand Down Expand Up @@ -1484,12 +1488,35 @@ RUN make -j $(getconf _NPROCESSORS_ONLN) \

#########################################################################################
#
# Layer "all-extensions"
# Layer "extensions-none"
#
#########################################################################################
FROM build-deps AS extensions-none

RUN mkdir /usr/local/pgsql

#########################################################################################
#
# Layer "extensions-minimal"
#
# This subset of extensions includes the extensions that we have in
# shared_preload_libraries by default.
#
#########################################################################################
FROM build-deps AS extensions-minimal

COPY --from=pgrag-build /usr/local/pgsql/ /usr/local/pgsql/
COPY --from=timescaledb-build /usr/local/pgsql/ /usr/local/pgsql/
COPY --from=pg_cron-build /usr/local/pgsql/ /usr/local/pgsql/
COPY --from=pg_partman-build /usr/local/pgsql/ /usr/local/pgsql/

#########################################################################################
#
# Layer "extensions-all"
# Bundle together all the extensions
#
#########################################################################################
FROM build-deps AS all-extensions
ARG PG_VERSION
FROM build-deps AS extensions-all

# Public extensions
COPY --from=postgis-build /usr/local/pgsql/ /usr/local/pgsql/
Expand Down Expand Up @@ -1531,7 +1558,13 @@ COPY --from=pg_partman-build /usr/local/pgsql/ /usr/local/pgsql/
COPY --from=pg_mooncake-build /usr/local/pgsql/ /usr/local/pgsql/
COPY --from=pg_repack-build /usr/local/pgsql/ /usr/local/pgsql/

COPY --from=neon-ext-build /usr/local/pgsql/ /usr/local/pgsql/
#########################################################################################
#
# Layer "neon-pg-ext-build"
# Includes Postgres and all the extensions chosen by EXTENSIONS arg.
#
#########################################################################################
FROM extensions-${EXTENSIONS} AS neon-pg-ext-build

#########################################################################################
#
Expand Down Expand Up @@ -1614,7 +1647,8 @@ RUN echo -e "--retry-connrefused\n--connect-timeout 15\n--retry 5\n--max-time 30
#
#########################################################################################
FROM neon-ext-build AS postgres-cleanup-layer
COPY --from=all-extensions /usr/local/pgsql /usr/local/pgsql

COPY --from=neon-pg-ext-build /usr/local/pgsql /usr/local/pgsql

# Remove binaries from /bin/ that we won't use (or would manually copy & install otherwise)
RUN cd /usr/local/pgsql/bin && rm -f ecpg raster2pgsql shp2pgsql pgtopo_export pgtopo_import pgsql2shp
Expand Down

1 comment on commit 6699a30

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7576 tests run: 7213 passed, 0 failed, 363 skipped (full report)


Flaky tests (1)

Postgres 14

Code coverage* (full report)

  • functions: 33.2% (8575 of 25805 functions)
  • lines: 49.1% (72142 of 147055 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
6699a30 at 2025-02-05T20:29:09.867Z :recycle:

Please sign in to comment.