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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Always use LF endings.
* text eol=lf
2 changes: 1 addition & 1 deletion .github/workflows/auto-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
-
name: Checkout Branch ${{ github.ref_name }}
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Create Pull Request
uses: bfren/pull-request@v2
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
-
name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
build:
strategy:
fail-fast: false
Expand All @@ -22,7 +22,7 @@ jobs:
steps:
-
name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Get repository name
run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
Expand All @@ -35,20 +35,20 @@ jobs:
id: version
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
-
name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
file: ./${{ matrix.postgresql }}/Dockerfile
Expand All @@ -59,7 +59,7 @@ jobs:
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: |
bfren/postgresql:postgresql${{ matrix.postgresql }}-dev
bfren/postgresql:postgresql${{ matrix.postgresql }}-${{ steps.version.outputs.contents }}-beta
bfren/postgresql:postgresql${{ matrix.postgresql }}-${{ steps.version.outputs.contents }}-dev
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
-
name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Get repository name
run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
Expand Down Expand Up @@ -46,20 +46,20 @@ jobs:
id: version
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
-
name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
file: ./${{ matrix.postgresql }}/Dockerfile
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
shell: bash
-
name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand Down
16 changes: 8 additions & 8 deletions 12/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
FROM bfren/alpine-s6:alpine3.18-4.5.9
FROM bfren/alpine-s6:alpine3.18-5.0.5

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

ARG BF_IMAGE
ARG BF_VERSION

ENV \
# set to "1" to compress backup sql files
POSTGRESQL_BACKUP_COMPRESS_FILES="0" \
# the number of days after which backups will be deleted
POSTGRESQL_BACKUP_KEEP_FOR_DAYS="28"

EXPOSE 5432

COPY ./overlay /
COPY ./12/overlay /

ENV \
# set to "1" to compress backup sql files
BF_PG_BACKUP_COMPRESS_FILES="0" \
# the duration for which backups will be kept
BF_PG_BACKUP_KEEP_FOR="28day"

RUN bf-install

VOLUME [ "/data", "/backup" ]
VOLUME [ "/backup", "/data" ]
2 changes: 1 addition & 1 deletion 12/overlay/tmp/POSTGRESQL_BUILD
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.16-r0
12.17-r0
2 changes: 1 addition & 1 deletion 12/overlay/tmp/POSTGRESQL_MINOR
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.16
12.17
16 changes: 8 additions & 8 deletions 13/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
FROM bfren/alpine-s6:alpine3.18-4.5.9
FROM bfren/alpine-s6:alpine3.18-5.0.5

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

ARG BF_IMAGE
ARG BF_VERSION

ENV \
# set to "1" to compress backup sql files
POSTGRESQL_BACKUP_COMPRESS_FILES="0" \
# the number of days after which backups will be deleted
POSTGRESQL_BACKUP_KEEP_FOR_DAYS="28"

EXPOSE 5432

COPY ./overlay /
COPY ./13/overlay /

ENV \
# set to "1" to compress backup sql files
BF_PG_BACKUP_COMPRESS_FILES="0" \
# the duration for which backups will be kept
BF_PG_BACKUP_KEEP_FOR="28day"

RUN bf-install

VOLUME [ "/data", "/backup" ]
VOLUME [ "/backup", "/data" ]
2 changes: 1 addition & 1 deletion 13/overlay/tmp/POSTGRESQL_BUILD
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13.12-r0
13.13-r0
2 changes: 1 addition & 1 deletion 13/overlay/tmp/POSTGRESQL_MINOR
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13.12
13.13
16 changes: 8 additions & 8 deletions 14/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
FROM bfren/alpine-s6:alpine3.18-4.5.9
FROM bfren/alpine-s6:alpine3.18-5.0.5

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

ARG BF_IMAGE
ARG BF_VERSION

ENV \
# set to "1" to compress backup sql files
POSTGRESQL_BACKUP_COMPRESS_FILES="0" \
# the number of days after which backups will be deleted
POSTGRESQL_BACKUP_KEEP_FOR_DAYS="28"

EXPOSE 5432

COPY ./overlay /
COPY ./14/overlay /

ENV \
# set to "1" to compress backup sql files
BF_PG_BACKUP_COMPRESS_FILES="0" \
# the duration for which backups will be kept
BF_PG_BACKUP_KEEP_FOR="28day"

RUN bf-install

VOLUME [ "/data", "/backup" ]
VOLUME [ "/backup", "/data" ]
2 changes: 1 addition & 1 deletion 14/overlay/tmp/POSTGRESQL_BUILD
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.9-r0
14.10-r0
2 changes: 1 addition & 1 deletion 14/overlay/tmp/POSTGRESQL_MINOR
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.9
14.10
16 changes: 8 additions & 8 deletions 15/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
FROM bfren/alpine-s6:alpine3.18-4.5.9
FROM bfren/alpine-s6:alpine3.18-5.0.5

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

ARG BF_IMAGE
ARG BF_VERSION

ENV \
# set to "1" to compress backup sql files
POSTGRESQL_BACKUP_COMPRESS_FILES="0" \
# the number of days after which backups will be deleted
POSTGRESQL_BACKUP_KEEP_FOR_DAYS="28"

EXPOSE 5432

COPY ./overlay /
COPY ./15/overlay /

ENV \
# set to "1" to compress backup sql files
BF_PG_BACKUP_COMPRESS_FILES="0" \
# the duration for which backups will be kept
BF_PG_BACKUP_KEEP_FOR="28day"

RUN bf-install

VOLUME [ "/data", "/backup" ]
VOLUME [ "/backup", "/data" ]
2 changes: 1 addition & 1 deletion 15/overlay/tmp/POSTGRESQL_BUILD
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15.4-r0
15.5-r0
2 changes: 1 addition & 1 deletion 15/overlay/tmp/POSTGRESQL_MINOR
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15.4
15.5
16 changes: 8 additions & 8 deletions Dockerfile.esh
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
FROM bfren/alpine-s6:alpine3.18-<%= ${BASE_REVISION} %>
FROM bfren/alpine-s6:alpine3.18-<%= ${BASE_VERSION} %>

LABEL org.opencontainers.image.source="https://github.com/bfren/docker-postgresql"

ARG BF_IMAGE
ARG BF_VERSION

ENV \
# set to "1" to compress backup sql files
POSTGRESQL_BACKUP_COMPRESS_FILES="0" \
# the number of days after which backups will be deleted
POSTGRESQL_BACKUP_KEEP_FOR_DAYS="28"

EXPOSE 5432

COPY ./overlay /
COPY ./<%= ${POSTGRESQL_MAJOR} %>/overlay /

ENV \
# set to "1" to compress backup sql files
BF_PG_BACKUP_COMPRESS_FILES="0" \
# the duration for which backups will be kept
BF_PG_BACKUP_KEEP_FOR="28day"

RUN bf-install

VOLUME [ "/data", "/backup" ]
VOLUME [ "/backup", "/data" ]
33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,28 @@ See [For Backups](#for-backups) for configuration variables.

### For Backups

| Variable | Values | Description | Default |
| ---------------------------------- | ---------------------------- | -------------------------------------------------------- | ------- |
| `POSTGRESQL_BACKUP_COMPRESS_FILES` | 0 or 1 | Whether or not to compress backup files (using gzip). | 0 |
| `POSTGRESQL_BACKUP_KEEP_FOR_DAYS` | 0: keep forever<br>Num: days | How many days to keep backups before auto-deleting them. | 14 |
| Variable | Values | Description | Default |
| ----------------------------- | ------------- | ----------------------------------------------------- | --------- |
| `PG_BACKUP_COMPRESS_FILES` | 0 or 1 | Whether or not to compress backup files (using bzip). | 0 |
| `BF_PG_BACKUP_KEEP_FOR` | Nu duration | The length of time to keep backups. | 28day |

### For Database

| Variable | Values | Description | Default |
| --------------------- | ------ | ----------------------------------------------------------------------------------------- | ----------------- |
| `POSTGRESQL_USERNAME` | string | Application username - will be used as database name if `POSTGRESQL_DATABASE` is not set. | *None* - required |
| `POSTGRESQL_PASSWORD` | string | Application password. | *None* - required |
| `POSTGRESQL_DATABASE` | string | Database name(s) - multiple databases can be separated by a comma. | *None* |
| Variable | Values | Description | Default |
| ----------------- | ------ | -------------------------------------------------------------------------------------------------------- | --------- |
| `PG_APPLICATION` | string | Application name - will be used as `PG_DATABASE`, `PG_PASSWORD` and `PG_USERNAME` if they are not set. | *None* |
| `PG_DATABASE` | string | Database name(s) - multiple databases can be separated by a comma. | *None* |
| `PG_PASSWORD` | string | Application password. | *None* |
| `PG_USERNAME` | string | Application username. | *None* |

## Helper Functions

| Function | Purpose | Usage |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| `db-backup` | Run backup manually. | `docker exec <<CONTAINER>> db-backup` |
| `db-exists` | Echoes '0' or '1' depending on whether or not the specified database exists on the server. | `docker exec <<CONTAINER>> db-exists "foo"` |
| `db-export` | Dumps the specified database as a SQL file to the root of the `/backup` volume. | `docker exec <<CONTAINER>> db-export <<DB_NAME>>` |
| `db-import` | Executes all files in the root of the `/backup` volume. | `docker exec <<CONTAINER>> db-import` |
| `db-restore` | Deletes all files in `/data` volume, then shuts container down - on restart, the container will restore from the specified backup. | `docker exec <<CONTAINER>> db-restore 202107180500` |
| `db-stop` | Stops the database server (will automatically terminate the container). | `docker exec <<CONTAINER>> db-stop` |
| Function | Arguments | Purpose | Usage |
| ------------- | ----------------- | ------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| `pg-dump` | *None* | Run backup manually. | `docker exec <<CONTAINER>> pg-dump` |
| `pg-export` | 1: Database name | Dumps the specified database as a SQL file to the root of the `/backup` volume. | `docker exec <<CONTAINER>> pg-export <<DB_NAME>>` |
| `pg-import` | 1: Database name | Executes all files in the root of the `/backup` volume. | `docker exec <<CONTAINER>> pg-import <<DB_NAME>>` |
| `pg-restore` | 1: Backup set | Deletes all files in `/data` volume, then restores from the specified backup dump. | `docker exec <<CONTAINER>> pg-restore 202107180500` |

## Licence

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.29
3.0.0
2 changes: 1 addition & 1 deletion VERSION_MAJOR
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2
3
2 changes: 1 addition & 1 deletion VERSION_MINOR
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3
3.0
6 changes: 3 additions & 3 deletions generate-dockerfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -euo pipefail

docker pull bfren/alpine

BASE_REVISION="4.5.9"
echo "Base: ${BASE_REVISION}"
BASE_VERSION="5.0.5"
echo "Base: ${BASE_VERSION}"

POSTGRESQL_VERSIONS="12 13 14 15"
for V in ${POSTGRESQL_VERSIONS} ; do
Expand All @@ -17,7 +17,7 @@ for V in ${POSTGRESQL_VERSIONS} ; do
-e BF_DEBUG=0 \
bfren/alpine esh \
"/ws/Dockerfile.esh" \
BASE_REVISION=${BASE_REVISION} \
BASE_VERSION=${BASE_VERSION} \
POSTGRESQL_MAJOR=${V}
)

Expand Down
7 changes: 3 additions & 4 deletions overlay/etc/bf/ch.d/10-postgresql
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/backup postgres:postgres 0770 0750
/data postgres:postgres 0770 0750
/run/postgresql postgres:postgres 0770 0750
/usr/bin/bf/db-exists root:root 0555
/backup postgres:postgres 0600 0700
/data postgres:postgres 0600 0700
/run/postgresql postgres:postgres 0600 0700
Loading