Add postgres with healthcheck

This commit is contained in:
Greyscale 2024-02-15 01:36:29 +01:00
parent cc245ee7ec
commit 42721205c9
No known key found for this signature in database
GPG key ID: 74BAFF55434DA4B2
4 changed files with 115 additions and 0 deletions

View file

@ -81,6 +81,15 @@ jobs:
contents: read
packages: write
postgres:
needs: qc-before
name: Postgres w/Healthcheck
uses: ./.github/workflows/postgres.yml
secrets: inherit
permissions:
contents: read
packages: write
mysql-proxy:
needs: qc-before
name: MySQL Proxy

91
.github/workflows/postgres.yml vendored Normal file
View file

@ -0,0 +1,91 @@
name: Postgres w/Healthcheck
permissions:
contents: read
packages: write
on:
workflow_call:
workflow_dispatch:
push:
branches:
- main
paths:
- postgres/**
- .github/workflows/postgres.yml
env:
should_push: ${{ github.ref == 'refs/heads/main' }}
jobs:
postgres-build:
name: "Build"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version:
- latest
- 16
- 16.2
- 16.1
- "16.0"
- 15
- 15.6
- 15.5
- 15.4
- 15.3
- 15.2
- 15.1
- "15.0"
- 14
- 14.11
- 14.10
- 14.9
- 14.8
- 14.7
- 14.6
- 14.5
- 14.4
- 14.3
- 14.2
- 14.1
- "14.0"
- 13
- 13.14
- 12
- 12.18
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: "Setup: Login to Docker Hub"
if: ${{ env.should_push }}
uses: docker/login-action@v3
with:
username: matthewbaggett
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: "Setup: Login to GHCR"
if: ${{ env.should_push }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: matthewbaggett
password: ${{ secrets.GHCR_PASSWORD }}
- uses: docker/build-push-action@v4
name: Build & Push
with:
context: postgres
platforms: ${{ env.ACT && 'linux/amd64' || 'linux/amd64,linux/arm64' }}
pull: true
push: ${{ env.should_push }}
tags: |
benzine/postgres:${{ matrix.version }}
ghcr.io/benzine-framework/postgres:${{ matrix.version }}
build-contexts: |
postgres:injected-version=docker-image://postgres:${{ matrix.version }}

13
postgres/Dockerfile Normal file
View file

@ -0,0 +1,13 @@
FROM postgres:injected-version
LABEL maintainer="Matthew Baggett <matthew@baggett.me>" \
org.label-schema.vcs-url="https://github.com/benzine-framework/docker" \
org.opencontainers.image.source="https://github.com/benzine-framework/docker"
# Add healthcheck script
COPY postgres_healthcheck.sh /usr/local/bin/postgres_healthcheck
RUN chmod +x /usr/local/bin/postgres_healthcheck
# Add healthcheck
HEALTHCHECK --start-period=30s --interval=10s --timeout=30s --retries=3 \
CMD ["/usr/local/bin/postgres_healthcheck"]

View file

@ -0,0 +1,2 @@
#!/bin/bash
PG_PASSWORD=$POSTGRES_PASSWORD pg_isready -U "$POSTGRES_USER"