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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
6 changes: 4 additions & 2 deletions .env.linux.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Make a copy of this file and name it ".env.linux"
# Used for Linux environments.
HOST_IP=192.168.1.100
PGMODELER_IMAGE=apazga/docker-pgmodeler:2.0.0-alpha
PROJECT_ROOT=/home/toto/git/db-pgmodeler
# Use a fixed version instead of the latest one, e.g. apazga/docker-pgmodeler:1.2.3
PGMODELER_IMAGE=apazga/docker-pgmodeler:latest
# Folder that contains the "data" directory (defaults to the folder of run.sh)
#PROJECT_ROOT=/home/toto/docker-pgmodeler
6 changes: 4 additions & 2 deletions .env.macos.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Make a copy of this file and name it ".env.macos"
# Used for MacOS environments.
HOST_IP=$(ifconfig en0 | grep "inet " | cut -d ' ' -f 2)
PGMODELER_IMAGE=apazga/docker-pgmodeler:2.0.0-alpha
PROJECT_ROOT=/Users/toto/docker-pgmodeler
# Use a fixed version instead of the latest one, e.g. apazga/docker-pgmodeler:1.2.3
PGMODELER_IMAGE=apazga/docker-pgmodeler:latest
# Folder that contains the "data" directory (defaults to the folder of the run script)
#PROJECT_ROOT=/Users/toto/docker-pgmodeler
7 changes: 7 additions & 0 deletions .env.windows.ps1.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Make a copy of this file and name it ".env.windows.ps1"
# Used by run.ps1 on Windows. Uncomment the values you want to change.
# $DISPLAY = '192.168.1.100:0.0'
# Use a fixed version instead of the latest one
# $PGMODELER_IMAGE = 'apazga/docker-pgmodeler:1.2.3'
# Folder that contains the "data" directory (defaults to the folder of run.ps1)
# $PROJECT_ROOT = 'D:\pgmodeler'
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
# Fix shell scripts with lines ending with "CRLF" on Windows
* text=auto
*.sh text eol=lf
# Dockerfile heredocs break with CRLF
Dockerfile text eol=lf
161 changes: 161 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: build-image

on:
workflow_call:
inputs:
version:
description: pgModeler version, e.g. 2.0.0-beta1
type: string
required: true
base_image:
description: Ubuntu image used to build and run pgModeler
type: string
required: true
latest:
description: Also tag the image as latest
type: boolean
default: false
push:
description: Publish the image and the git tag (false = build and test only)
type: boolean
default: false

permissions:
contents: read

env:
IMAGE: apazga/docker-pgmodeler

jobs:
build:
name: build (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 180
strategy:
fail-fast: true
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: ubuntu-24.04
- arch: arm64
platform: linux/arm64
runner: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v7

- uses: docker/setup-buildx-action@v4

- name: Log in to Docker Hub
if: inputs.push
uses: docker/login-action@v4
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Image labels
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE }}
labels: |
org.opencontainers.image.title=pgModeler
org.opencontainers.image.description=pgModeler ${{ inputs.version }} running in a Docker container
org.opencontainers.image.version=${{ inputs.version }}

- name: Build
uses: docker/build-push-action@v7
with:
context: .
platforms: ${{ matrix.platform }}
build-args: |
PG_VERSION=${{ inputs.version }}
BASE_IMAGE=${{ inputs.base_image }}
labels: ${{ steps.meta.outputs.labels }}
tags: pgmodeler-smoke:${{ inputs.version }}
load: true

- name: Smoke test
env:
VERSION: ${{ inputs.version }}
run: bash scripts/smoke-test.sh "pgmodeler-smoke:$VERSION" "$VERSION"

- name: Push by digest
id: push
if: inputs.push
uses: docker/build-push-action@v7
with:
context: .
platforms: ${{ matrix.platform }}
build-args: |
PG_VERSION=${{ inputs.version }}
BASE_IMAGE=${{ inputs.base_image }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
if: inputs.push
env:
DIGEST: ${{ steps.push.outputs.digest }}
run: |
mkdir -p "$RUNNER_TEMP/digests"
touch "$RUNNER_TEMP/digests/${DIGEST#sha256:}"

- name: Upload digest
if: inputs.push
uses: actions/upload-artifact@v7
with:
name: digests-${{ matrix.arch }}-${{ inputs.version }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1

merge:
if: inputs.push
needs: build
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v7

- name: Download digests
uses: actions/download-artifact@v8
with:
# The version goes last so 2.1.0 does not also match the digests of 2.1.0-rc1
pattern: digests-*-${{ inputs.version }}
path: ${{ runner.temp }}/digests
merge-multiple: true

- uses: docker/setup-buildx-action@v4

- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Publish multi-arch image
working-directory: ${{ runner.temp }}/digests
env:
VERSION: ${{ inputs.version }}
LATEST: ${{ inputs.latest }}
run: |
digests=(*)
if [ "${#digests[@]}" -ne 2 ]; then
echo "::error::expected 2 digests (amd64 + arm64), found ${#digests[@]}"
exit 1
fi
tags=(-t "$IMAGE:$VERSION")
if [ "$LATEST" = true ]; then
tags+=(-t "$IMAGE:latest")
fi
docker buildx imagetools create "${tags[@]}" "${digests[@]/#/$IMAGE@sha256:}"
docker buildx imagetools inspect "$IMAGE:$VERSION"

- name: Tag repository
env:
VERSION: ${{ inputs.version }}
run: |
git tag -f "$VERSION" "$GITHUB_SHA"
git push -f origin "refs/tags/$VERSION"
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: release

on:
schedule:
- cron: "0 4 * * 1" # Mondays at 04:00 UTC
workflow_dispatch:
inputs:
versions:
description: Versions to build, comma separated (empty = every version missing on Docker Hub)
type: string
default: ""
force:
description: Rebuild the given versions even if they are already on Docker Hub
type: boolean
default: false
dry_run:
description: Only list the versions that would be built
type: boolean
default: false
pull_request:
paths:
- Dockerfile
- .dockerignore
- scripts/**
- .github/workflows/**
push:
branches: [master]
paths:
- Dockerfile
- .dockerignore
- scripts/**
- .github/workflows/**

permissions:
contents: read

concurrency:
# Publishing runs queue one after another; validation runs never replace a pending publish
group: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && 'release' || format('validate-{0}', github.ref) }}
cancel-in-progress: ${{ github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' }}

jobs:
detect:
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.detect.outputs.matrix }}
count: ${{ steps.detect.outputs.count }}
steps:
- uses: actions/checkout@v7

- name: Test version detection
run: python3 -m unittest discover -s scripts -v

- name: Detect versions to build
id: detect
env:
GITHUB_TOKEN: ${{ github.token }}
EVENT: ${{ github.event_name }}
VERSIONS: ${{ inputs.versions }}
FORCE: ${{ inputs.force }}
run: |
args=()
if [ "$EVENT" = pull_request ] || [ "$EVENT" = push ]; then
args+=(--validate)
fi
if [ -n "$VERSIONS" ]; then
args+=(--versions "$VERSIONS")
fi
if [ "$FORCE" = true ]; then
args+=(--force)
fi
python3 scripts/detect_versions.py "${args[@]}"

build:
name: ${{ matrix.version }}
needs: detect
if: needs.detect.outputs.count != '0' && !inputs.dry_run
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.detect.outputs.matrix) }}
permissions:
contents: write
uses: ./.github/workflows/build-image.yml
with:
version: ${{ matrix.version }}
base_image: ${{ matrix.base_image }}
latest: ${{ matrix.latest }}
push: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
secrets: inherit
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.env.linux
.env.macos
.env.windows.ps1
.run.ps1
.run.ps1
__pycache__/
Loading