Created
October 4, 2019 17:49
-
-
Save btsuhako/8880da9cccc4b9b336c6d47cd7dbc23e to your computer and use it in GitHub Desktop.
Docker image for pg_upgrade 10 -> 11 with PostGIS 2.5
This file contains hidden or 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
#!/bin/bash | |
set -e | |
if [ "$#" -eq 0 -o "${1:0:1}" = '-' ]; then | |
set -- pg_upgrade "$@" | |
fi | |
if [ "$1" = 'pg_upgrade' -a "$(id -u)" = '0' ]; then | |
mkdir -p "$PGDATAOLD" "$PGDATANEW" | |
chmod 700 "$PGDATAOLD" "$PGDATANEW" | |
chown postgres . | |
chown -R postgres "$PGDATAOLD" "$PGDATANEW" | |
exec gosu postgres "$BASH_SOURCE" "$@" | |
fi | |
if [ "$1" = 'pg_upgrade' ]; then | |
if [ ! -s "$PGDATANEW/PG_VERSION" ]; then | |
PGDATA="$PGDATANEW" eval "initdb $POSTGRES_INITDB_ARGS" | |
fi | |
fi | |
exec "$@" |
This file contains hidden or 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
FROM mdillon/postgis:11 | |
RUN sed -i 's/$/ 10/' /etc/apt/sources.list.d/pgdg.list | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
postgresql-10 postgresql-10-postgis-2.5 postgresql-10-postgis-2.5-scripts \ | |
&& rm -rf /var/lib/apt/lists/* | |
ENV PGBINOLD /usr/lib/postgresql/10/bin | |
ENV PGBINNEW /usr/lib/postgresql/11/bin | |
ENV PGDATAOLD /var/lib/postgresql/10/data | |
ENV PGDATANEW /var/lib/postgresql/11/data | |
RUN mkdir -p "$PGDATAOLD" "$PGDATANEW" \ | |
&& chown -R postgres:postgres /var/lib/postgresql | |
WORKDIR /var/lib/postgresql | |
COPY docker-upgrade /usr/local/bin/ | |
ENTRYPOINT ["docker-upgrade"] | |
# recommended: --link | |
CMD ["pg_upgrade"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment