Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pg init container #13

Merged
merged 2 commits into from
Sep 18, 2024
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
52 changes: 52 additions & 0 deletions .github/workflows/pg-init.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: pg init container

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

permissions:
# Checkout repository
contents: read
# Push container images
packages: write

jobs:
build:
runs-on: ubuntu-24.04
env:
IMAGE_NAME: gardenlinux/glvd-postgres-init
IMAGE_TAG: latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install qemu dependency for multi-arch build
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- run: |
gh run download 10905326712 -n glvd.sql --repo gardenlinux/glvd-contrib
env:
GH_TOKEN: ${{ github.token }}
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ env.IMAGE_TAG }}
platforms: linux/amd64, linux/arm64
containerfiles: |
./Containerfile.pg-init

- name: Push To ghcr.io
id: push-to-ghcr
if: ${{ github.event_name != 'pull_request' }}
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions Containerfile.pg-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM debian

ENV PGHOST glvd
ENV PGPORT 5432
ENV PGDATABASE glvd
ENV PGUSER glvd
ENV PGPASSWORD glvd

RUN apt-get update && apt-get install -y postgresql-client

COPY glvd.sql /glvd.sql
COPY pg-init-entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
8 changes: 8 additions & 0 deletions pg-init-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail

echo "$PGHOST:$PGPORT:$PGDATABASE:$PGUSER:$PGPASSWORD" > ~/.pgpass
chmod 0600 ~/.pgpass

dropdb glvd
psql glvd -f /glvd.sql