-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from hotosm/build/pg-upgrade-bash-script
Overhaul postgres upgrade process v14 --> v16
- Loading branch information
Showing
7 changed files
with
111 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,37 @@ | ||
FROM tianon/postgres-upgrade:14-to-16 | ||
|
||
RUN set -ex \ | ||
&& apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install \ | ||
-y --no-install-recommends \ | ||
"postgresql-14-postgis-3" \ | ||
"postgresql-16-postgis-3" \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
FROM docker.io/postgis/postgis:14-3.4-alpine as pg14 | ||
FROM docker.io/postgis/postgis:15-3.4-alpine as pg15 | ||
FROM docker.io/postgis/postgis:16-3.4-alpine as pg16 | ||
FROM docker.io/pgautoupgrade/pgautoupgrade:16-alpine as pgautoupgrade | ||
|
||
# Original entrypoint copied overwritten in /usr/local/bin, so copy elsewhere | ||
RUN cp /usr/local/bin/docker-entrypoint.sh /docker-entrypoint.sh | ||
|
||
# Remove libs for Postgres < v14 | ||
RUN rm -rf \ | ||
/usr/local-pg9.5 \ | ||
/usr/local-pg9.6 \ | ||
/usr/local-pg10 \ | ||
/usr/local-pg11 \ | ||
/usr/local-pg12 \ | ||
/usr/local-pg13 | ||
|
||
# Copy in PostGIS libs / bins | ||
COPY --from=pg16 /_pgis*.* / | ||
COPY --from=pg16 /usr/lib /usr/lib | ||
|
||
# Copy extensions for postgresql 16 | ||
COPY --from=pg16 /usr/local /usr/local | ||
# Copy all extensions for postgresql 15 | ||
COPY --from=pg15 /usr/local/lib/postgresql /usr/local-pg15/lib/postgresql | ||
# Copy all extensions for postgresql 14 | ||
COPY --from=pg14 /usr/local/lib/postgresql /usr/local-pg14/lib/postgresql | ||
|
||
# Squash image to reduce size | ||
FROM scratch | ||
COPY --from=pgautoupgrade / / | ||
ENV \ | ||
PGTARGET=16 \ | ||
PGDATA=/var/lib/postgresql/data | ||
WORKDIR /var/lib/postgresql | ||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
CMD ["postgres"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
# Postgres Version Upgrades | ||
|
||
- Based on images from https://github.com/tianon/docker-postgres-upgrade | ||
- Based on images from https://github.com/pgautoupgrade/docker-pgautoupgrade | ||
- Adds the PostGIS dependency and builds an image for our repo. | ||
- The image is used for upgrading between containerised Postgres versions. | ||
|
||
```bash | ||
# From the repo root | ||
bash contrib/pg-upgrade/upgrade-db.sh | ||
docker compose --file contrib/pg-upgrade/docker-compose.yml \ | ||
up --abort-on-container-failure | ||
``` | ||
|
||
This will start the upgrade, wait for completion, then mount | ||
the data and start the new Postgres 16 container. | ||
|
||
> Note it is important to shut down the postgres container first, or | ||
> a postmaster error will be encountered. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters