Docker images for postgres extended with management bash scripts.

feat: added new versions of PostgreSQL and PostGIS

+84 -21
+26 -21
Makefile
··· 1 1 # Variables 2 2 # ------------------------------------------------------------------------------ 3 - POSTGRES_IMAGE_ID=marcosgabarda/postgres 4 - POSTGIS_IMAGE_ID=marcosgabarda/postgis 3 + POSTGRES_IMAGE_ID := marcosgabarda/postgres 4 + POSTGIS_IMAGE_ID := marcosgabarda/postgis 5 5 6 - .PHONY: build_postgres push_postgres build_postgis push_postgis 6 + # Versions to build 7 + # ------------------------------------------------------------------------------ 8 + POSTGRES_VERSIONS := 10 11 12 13 14 15 9 + POSTGRES_LATEST_VERSION := 16 10 + POSTGIS_VERSIONS := 11-2.5 12-3.0 13-3.1 14-3.4 15-3.4 11 + POSTGIS_LATEST_VERSION := 16-3.4 12 + 13 + .PHONY: build_postgres push_postgres build_postgis push_postgis build push 7 14 8 15 build_postgres: 9 - docker buildx build . -f ./postgres/10/Dockerfile --tag ${POSTGRES_IMAGE_ID}:10 --platform linux/amd64,linux/arm64 10 - docker buildx build . -f ./postgres/11/Dockerfile --tag ${POSTGRES_IMAGE_ID}:11 --platform linux/amd64,linux/arm64 11 - docker buildx build . -f ./postgres/12/Dockerfile --tag ${POSTGRES_IMAGE_ID}:12 --platform linux/amd64,linux/arm64 12 - docker buildx build . -f ./postgres/13/Dockerfile --tag ${POSTGRES_IMAGE_ID}:13 --platform linux/amd64,linux/arm64 13 - docker buildx build . -f ./postgres/14/Dockerfile --tag ${POSTGRES_IMAGE_ID}:14 --tag ${POSTGRES_IMAGE_ID}:latest --platform linux/amd64,linux/arm64 16 + @for version in $(POSTGRES_VERSIONS) ; do \ 17 + docker buildx build . -f ./postgres/$$version/Dockerfile --tag ${POSTGRES_IMAGE_ID}:$$version --platform linux/amd64,linux/arm64 ; \ 18 + done 19 + docker buildx build . -f ./postgres/${POSTGRES_LATEST_VERSION}/Dockerfile --tag ${POSTGRES_IMAGE_ID}:${POSTGRES_LATEST_VERSION} --tag ${POSTGRES_IMAGE_ID}:latest --platform linux/amd64,linux/arm64 14 20 15 21 push_postgres: 16 - docker buildx build . -f ./postgres/10/Dockerfile --tag ${POSTGRES_IMAGE_ID}:10 --platform linux/amd64,linux/arm64 --push 17 - docker buildx build . -f ./postgres/11/Dockerfile --tag ${POSTGRES_IMAGE_ID}:11 --platform linux/amd64,linux/arm64 --push 18 - docker buildx build . -f ./postgres/12/Dockerfile --tag ${POSTGRES_IMAGE_ID}:12 --platform linux/amd64,linux/arm64 --push 19 - docker buildx build . -f ./postgres/13/Dockerfile --tag ${POSTGRES_IMAGE_ID}:13 --platform linux/amd64,linux/arm64 --push 20 - docker buildx build . -f ./postgres/14/Dockerfile --tag ${POSTGRES_IMAGE_ID}:14 --tag ${POSTGRES_IMAGE_ID}:latest --platform linux/amd64,linux/arm64 --push 22 + @for version in $(POSTGRES_VERSIONS) ; do \ 23 + docker buildx build . -f ./postgres/$$version/Dockerfile --tag ${POSTGRES_IMAGE_ID}:$$version --platform linux/amd64,linux/arm64 --push ; \ 24 + done 25 + docker buildx build . -f ./postgres/${POSTGRES_LATEST_VERSION}/Dockerfile --tag ${POSTGRES_IMAGE_ID}:${POSTGRES_LATEST_VERSION} --tag ${POSTGRES_IMAGE_ID}:latest --platform linux/amd64,linux/arm64 --push 21 26 22 27 build_postgis: 23 - docker buildx build . -f ./postgis/11/Dockerfile --tag ${POSTGIS_IMAGE_ID}:11-2.5 --tag ${POSTGIS_IMAGE_ID}:11 --platform linux/amd64,linux/arm64 24 - docker buildx build . -f ./postgis/12/Dockerfile --tag ${POSTGIS_IMAGE_ID}:12-3.0 --tag ${POSTGIS_IMAGE_ID}:12 --platform linux/amd64,linux/arm64 25 - docker buildx build . -f ./postgis/13/Dockerfile --tag ${POSTGIS_IMAGE_ID}:13-3.1 --tag ${POSTGIS_IMAGE_ID}:13 --platform linux/amd64,linux/arm64 26 - docker buildx build . -f ./postgis/14/Dockerfile --tag ${POSTGIS_IMAGE_ID}:14-3.4 --tag ${POSTGIS_IMAGE_ID}:13 --tag ${POSTGIS_IMAGE_ID}:latest --platform linux/amd64,linux/arm64 28 + @for version in $(POSTGIS_VERSIONS) ; do \ 29 + docker buildx build . -f ./postgis/$$version/Dockerfile --tag ${POSTGIS_IMAGE_ID}:$$version --tag ${POSTGIS_IMAGE_ID}:$(word 1, $(subst -, ,$$version)) --platform linux/amd64,linux/arm64 ; \ 30 + done 31 + docker buildx build . -f ./postgis/${POSTGIS_LATEST_VERSION}/Dockerfile --tag ${POSTGIS_IMAGE_ID}:${POSTGIS_LATEST_VERSION} --tag ${POSTGIS_IMAGE_ID}:$(word 1, $(subst -, ,$(POSTGIS_LATEST_VERSION))) --tag ${POSTGIS_IMAGE_ID}:latest --platform linux/amd64,linux/arm64 27 32 28 33 push_postgis: 29 - docker buildx build . -f ./postgis/11/Dockerfile --tag ${POSTGIS_IMAGE_ID}:11-2.5 --tag ${POSTGIS_IMAGE_ID}:11 --platform linux/amd64,linux/arm64 --push 30 - docker buildx build . -f ./postgis/12/Dockerfile --tag ${POSTGIS_IMAGE_ID}:12-3.0 --tag ${POSTGIS_IMAGE_ID}:12 --platform linux/amd64,linux/arm64 --push 31 - docker buildx build . -f ./postgis/13/Dockerfile --tag ${POSTGIS_IMAGE_ID}:13-3.1 --tag ${POSTGIS_IMAGE_ID}:13 --platform linux/amd64,linux/arm64 --push 32 - docker buildx build . -f ./postgis/14/Dockerfile --tag ${POSTGIS_IMAGE_ID}:14-3.4 --tag ${POSTGIS_IMAGE_ID}:14 --tag ${POSTGIS_IMAGE_ID}:latest --platform linux/amd64,linux/arm64 --push 34 + @for version in $(POSTGIS_VERSIONS) ; do \ 35 + docker buildx build . -f ./postgis/$$version/Dockerfile --tag ${POSTGIS_IMAGE_ID}:$$version --tag ${POSTGIS_IMAGE_ID}:$(word 1, $(subst -, ,$$version)) --platform linux/amd64,linux/arm64 --push ; \ 36 + done 37 + docker buildx build . -f ./postgis/${POSTGIS_LATEST_VERSION}/Dockerfile --tag ${POSTGIS_IMAGE_ID}:${POSTGIS_LATEST_VERSION} --tag ${POSTGIS_IMAGE_ID}:14 --tag ${POSTGIS_IMAGE_ID}:latest --platform linux/amd64,linux/arm64 --push 33 38 34 39 build: build_postgres build_postgis 35 40
+34
README.md
··· 13 13 14 14 Example of a `docker-compose.yml` file that uses this image: 15 15 16 + ```yaml 16 17 version: '3' 17 18 18 19 volumes: ··· 32 33 - postgres_backups:/backups 33 34 env_file: 34 35 - ./.env 36 + ``` 37 + 38 + ## Maintenance commands 39 + 40 + This images adds commands to the original PostgreSQL image for maintenance proposes. 41 + 42 + ### Create a database backup 43 + 44 + Creates a backup of the database. Usage: 45 + 46 + $ docker-compose -f <environment>.yml (exec |run --rm) postgres backup 47 + 48 + ### View backups 49 + 50 + Views a list of all created backups of the database. Usage: 51 + 52 + $ docker-compose -f <environment>.yml (exec |run --rm) postgres backups 53 + 54 + ### Creates a read only user 55 + 56 + Creates a read only user. Usage: 57 + 58 + $ docker-compose -f <environment>.yml (exec |run --rm) postgres createreaduser 59 + 60 + ### Restore database from a backup 61 + 62 + Restores the indicated database backup. Usage: 63 + 64 + $ docker-compose -f <environment>.yml (exec |run --rm) postgres restore <1> 65 + 66 + Parameters: 67 + 68 + * `<1>` filename of an existing backup.
postgis/11/Dockerfile postgis/11-2.5/Dockerfile
postgis/12/Dockerfile postgis/12-3.0/Dockerfile
postgis/13/Dockerfile postgis/13-3.1/Dockerfile
postgis/14/Dockerfile postgis/14-3.4/Dockerfile
+6
postgis/15-3.4/Dockerfile
··· 1 + FROM postgis/postgis:15-3.4-alpine 2 + 3 + COPY ./maintenance /usr/local/bin/maintenance 4 + RUN chmod +x /usr/local/bin/maintenance/* 5 + RUN mv /usr/local/bin/maintenance/* /usr/local/bin \ 6 + && rmdir /usr/local/bin/maintenance
+6
postgis/16-3.4/Dockerfile
··· 1 + FROM postgis/postgis:16-3.4-alpine 2 + 3 + COPY ./maintenance /usr/local/bin/maintenance 4 + RUN chmod +x /usr/local/bin/maintenance/* 5 + RUN mv /usr/local/bin/maintenance/* /usr/local/bin \ 6 + && rmdir /usr/local/bin/maintenance
+6
postgres/15/Dockerfile
··· 1 + FROM postgres:15 2 + 3 + COPY ./maintenance /usr/local/bin/maintenance 4 + RUN chmod +x /usr/local/bin/maintenance/* 5 + RUN mv /usr/local/bin/maintenance/* /usr/local/bin \ 6 + && rmdir /usr/local/bin/maintenance
+6
postgres/16/Dockerfile
··· 1 + FROM postgres:16 2 + 3 + COPY ./maintenance /usr/local/bin/maintenance 4 + RUN chmod +x /usr/local/bin/maintenance/* 5 + RUN mv /usr/local/bin/maintenance/* /usr/local/bin \ 6 + && rmdir /usr/local/bin/maintenance