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
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git
.github
graphify-out
*.md
LICENSE
install.sh
completions
63 changes: 63 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Docker

on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
smoke:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build image
run: docker build -t pgsync:ci .

- name: Version smoke test
run: docker run --rm pgsync:ci --version

- name: Compose sync smoke test
run: PGSYNC_IMAGE=pgsync:ci docker compose run --rm pgsync

publish:
runs-on: ubuntu-latest
needs: smoke
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=
type=raw,value=latest,enable={{is_default_branch}}

- uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
graphify-out/
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM postgres:16-bookworm

LABEL org.opencontainers.image.source="https://github.com/mamahoos/pgsync"
LABEL org.opencontainers.image.description="PostgreSQL logical sync (pg_dump | psql)"

COPY pgsync.sh /usr/local/bin/pgsync
RUN chmod 755 /usr/local/bin/pgsync

ENTRYPOINT ["pgsync"]
CMD ["--help"]
54 changes: 54 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Local demo / CI smoke test: two Postgres instances + one-shot sync.
#
# Smoke test:
# docker compose run --rm pgsync
#
# Custom URIs (external clusters):
# docker compose run --rm pgsync \
# -s 'postgresql://user:pass@host:5432/src' \
# -t 'postgresql://user:pass@host:5432/dst'
#
# Pull from GHCR instead of building locally:
# PGSYNC_IMAGE=ghcr.io/mamahoos/pgsync:latest docker compose run --rm pgsync

services:
source:
image: postgres:16-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: app
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d app"]
interval: 2s
timeout: 5s
retries: 15
start_period: 5s

target:
image: postgres:16-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: app
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d app"]
interval: 2s
timeout: 5s
retries: 15
start_period: 5s

pgsync:
image: ${PGSYNC_IMAGE:-ghcr.io/mamahoos/pgsync:latest}
build: .
depends_on:
source:
condition: service_healthy
target:
condition: service_healthy
command:
- -s
- postgresql://postgres:postgres@source:5432/app
- -t
- postgresql://postgres:postgres@target:5432/app
- -v
Loading