Skip to content

Commit

Permalink
feat: customized timescaledb docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazmi35 committed Oct 8, 2024
1 parent 0ae139e commit faf45b5
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Build & Push OCI Image to OCI Image Registry

on:
workflow_call:
inputs:
workdirs:
required: true
type: string
images:
required: true
type: string
secrets:
ghcr-username:
required: true
ghcr-access-token:
required: true

permissions:
contents: read
packages: write

jobs:
build:
continue-on-error: true
strategy:
matrix: # REFS: https://github.community/t/reusable-workflow-with-strategy-matrix/205676
workdir: ${{ fromJSON(inputs.workdirs) }}

runs-on: ubuntu-latest

steps:
- name: Check Out Repository
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

- name: Set up QEMU for Docker Buildx
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2.10.0

- name: Set up Node.js for extracting recipe from Dockerfile
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2

- name: Extract recipe from Dockerfile
id: recipe
run: |
TAGS=`npm exec -sy @hazmi35/extract-docker-baseimg-recipe ${{ matrix.workdir }}/Dockerfile tags`
PLATFORMS=`npm exec -sy @hazmi35/extract-docker-baseimg-recipe ${{ matrix.workdir }}/Dockerfile platforms`
VARIANT=`npm exec -sy @hazmi35/extract-docker-baseimg-recipe ${{ matrix.workdir }}/Dockerfile variant`
echo TAGS: $TAGS
echo PLATFORMS: $PLATFORMS
echo VARIANT: $VARIANT
echo "::set-output name=tags::${TAGS//$', '/'%0A'}"
echo "::set-output name=platforms::${PLATFORMS//$', '/'%0A'}"
echo "::set-output name=variant::$VARIANT"
- name: Generate Docker image metadata
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # v4.6.0
id: meta
with:
images: ${{ inputs.images }}
tags: |
${{ steps.recipe.outputs.tags }}
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
with:
registry: ghcr.io
username: ${{ secrets.ghcr-username }}
password: ${{ secrets.ghcr-access-token }}

- name: Build and push the Docker image from the specified Dockerfile
id: docker_build
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
with:
context: .
file: ./${{ matrix.workdir }}/Dockerfile
platforms: |
${{ steps.recipe.outputs.platforms }}
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
30 changes: 30 additions & 0 deletions .github/workflows/postgres-16.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build & Push Postgres 16 OCI Image to OCI Image Registry

on:
push:
branches:
- main
paths:
- "16/Dockerfile"
pull_request:
branches:
- main
paths:
- "16/Dockerfile"

jobs:
workdirs:
uses: ./.github/workflows/specify-workdir.yaml
with:
base-dir: 18

image:
uses: ./.github/workflows/build.yaml
needs: workdirs
with:
workdirs: '["16"]'
images: |
ghcr.io/takodotid/postgres
secrets:
ghcr-username: ${{ github.repository_owner }}
ghcr-access-token: ${{ secrets.GITHUB_TOKEN }}
File renamed without changes.

0 comments on commit faf45b5

Please sign in to comment.