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

publish docker images/image updates for major versions #1372

Merged
merged 97 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
c37f69b
feat: orioledb-17 Docker image and publish workflow
samrose Dec 9, 2024
7ba55bf
feat: refactor to build docker images from major versions
samrose Dec 13, 2024
ee89cc2
feat: gen common vars hcl file
samrose Dec 13, 2024
c53895a
chore: cleanup
samrose Dec 13, 2024
1b17127
chore: adj trigger for run in PR`
samrose Dec 13, 2024
4c45cf1
chore: trigger release all major vers
samrose Dec 13, 2024
f4eb159
chore: trigger on any path
samrose Dec 13, 2024
74c5905
chore: cleanup version handling
samrose Dec 13, 2024
6bd45b1
chore: simplify name matching
samrose Dec 13, 2024
2be76f4
chore: matrix on version and arch in build_release_image
samrose Dec 13, 2024
7f16807
chore: try to get json formatting correct
samrose Dec 13, 2024
e5cbc7c
chore: more fixes to json parse
samrose Dec 13, 2024
6731dab
feat: collect all versions into file, then array
samrose Dec 13, 2024
7a69907
chore: try to account for gh action handling
samrose Dec 13, 2024
2addaab
chore: output single matrix for each version
samrose Dec 13, 2024
19f50db
chore: more fixes to matrix handling
samrose Dec 13, 2024
d3392e0
chore : fix output versions
samrose Dec 13, 2024
33f8ae3
chore: matrix in all tasks
samrose Dec 16, 2024
ec1b4ac
chore: refactor matrix handling
samrose Dec 16, 2024
cf0702c
chore: fix syntax
samrose Dec 16, 2024
7b5c419
chore: look in the right dir
samrose Dec 16, 2024
4395c35
chore: need to pass full tag
samrose Dec 16, 2024
f7b36dc
fix: formatting
samrose Dec 16, 2024
2a5b6a4
chore: strip the prefix when passing to mirror.yml
samrose Dec 16, 2024
761d019
chore: get version formatted to pass to mirror.yml
samrose Dec 16, 2024
9f7ee62
fix: typo
samrose Dec 16, 2024
94c32a5
chore: fix vars
samrose Dec 17, 2024
2c94c9c
fix: tryo to pass the version
samrose Dec 17, 2024
4dbac71
chore: matrix on version and arch
samrose Dec 17, 2024
16788ef
chore: try to account for orioledb version issue
samrose Dec 17, 2024
de3b59d
chore: remove version
samrose Dec 17, 2024
9ef1aae
chore: reading the version info directly from vars.yml
samrose Dec 17, 2024
1882226
chore: force string context
samrose Dec 17, 2024
63c0222
chore: fixing logic
samrose Dec 17, 2024
4ce2b4f
chore: fix string handling logic
samrose Dec 17, 2024
d80e8b3
chore: use sed and grep instead
samrose Dec 17, 2024
a935b19
chore: revert this to working version
samrose Dec 17, 2024
a2323c2
chore: version extraction
samrose Dec 17, 2024
c9ff94f
chore: different logic on version processing if stmnt
samrose Dec 17, 2024
baa41b0
chore: try to avoid jq involvement in this section
samrose Dec 17, 2024
f65c5e6
chore: back to this version
samrose Dec 18, 2024
ea2bc3b
chore: refactor using nushell where scripting needed
samrose Dec 18, 2024
2c63e7a
chore: use data from previous step
samrose Dec 18, 2024
43ae0dc
chore: install with snap
samrose Dec 18, 2024
b91e4a7
chore: raw output on json
samrose Dec 18, 2024
4454104
chore: should be able to run on ephemeral runners
samrose Dec 18, 2024
cd65a52
chore: incrementing changes to matrix
samrose Dec 18, 2024
66b964c
chore: just use special key name if present
samrose Dec 18, 2024
75d2a56
chore: account for postgres namespace in matrix
samrose Dec 18, 2024
faa565a
chore: pg_version should be key/value
samrose Dec 18, 2024
1e46a6e
chrore: ubuntu latest
samrose Dec 18, 2024
4168531
chore: needs arm-runner after all
samrose Dec 18, 2024
030d3c8
chore: source nushell from nix
samrose Dec 18, 2024
f03c65a
chore: cannot have uses and run keys on same id
samrose Dec 18, 2024
413c7a4
chore: detect runner and adjust the way command is run
samrose Dec 18, 2024
084b300
chore: formatting
samrose Dec 18, 2024
126e974
chore: make sure env var can be appended in all contexts
samrose Dec 18, 2024
4a6db10
chore: outputs instead of env
samrose Dec 19, 2024
ad254d5
chore: fix get_publish_version
samrose Dec 19, 2024
8c777d0
chore: handle oriole
samrose Dec 19, 2024
98c9bee
chore: remove base64 encoding
samrose Dec 19, 2024
613b45c
ore: raw json
samrose Dec 19, 2024
2c662f2
chore: ensure proper variable naming
samrose Dec 19, 2024
9df7187
chore: use the matrix config we already have access to
samrose Dec 19, 2024
47e3258
chore: handling architecture
samrose Dec 19, 2024
369f534
chore directly use matrix
samrose Dec 19, 2024
cd2e596
chore: process each version
samrose Dec 19, 2024
e862161
chore: matrix_json variable
samrose Dec 19, 2024
cb685ba
fix: mirroring the merged manifest instead of per arch image
samrose Dec 20, 2024
d66ac71
chore: using tags from merge_manifest
samrose Dec 20, 2024
c40f455
chore: no longer need get_publish_version at all
samrose Dec 20, 2024
b8f58e6
chore: combine tags in outputs at the end of merge_manifest
samrose Dec 20, 2024
0d7253e
chore: cleanup steps to unbreak yaml
samrose Dec 20, 2024
60b2ea2
chore: no from json
samrose Dec 20, 2024
6ce3238
chore: try to build up json over iterations
samrose Dec 20, 2024
1b9fd7e
chore: use the github outputs array
samrose Dec 20, 2024
0d50263
chore: first collect all versions into array then output json array
samrose Dec 20, 2024
7664b4e
chore: debug mainfest output
samrose Dec 20, 2024
ce09b8e
chore: store the results data in artifacts
samrose Dec 20, 2024
de42c0e
chore: unique upload, then download and combine
samrose Dec 20, 2024
458d3db
fix: re-add actions and login
samrose Dec 20, 2024
74d63aa
chore: try quotes for name matching
samrose Dec 20, 2024
16cfb3f
chore: utilise versions from prepare for download of artifact
samrose Dec 20, 2024
60dd2dd
chore: format correctly for nushell
samrose Dec 20, 2024
6f7ce25
chore: parse matrix config directly
samrose Dec 20, 2024
90a45f4
chore: convert table to list of strings
samrose Dec 20, 2024
e42ab66
chore:rm redundant
samrose Dec 21, 2024
62f5ee2
chore: add debug
samrose Dec 21, 2024
f72840d
chore: from json
samrose Dec 21, 2024
4ab2e18
chore: download with pattern
samrose Dec 21, 2024
825dd85
chore: use list operations
samrose Dec 21, 2024
c619fb8
chore: include and debug
samrose Dec 21, 2024
2ec2b5c
chore: extract version
samrose Dec 21, 2024
b8399b9
chore: set up for merge to develop
samrose Dec 21, 2024
c2792dc
chore: add permission to proper dir
samrose Dec 21, 2024
c704342
chore: remove old files
samrose Dec 21, 2024
c571b3f
chore: newline
samrose Dec 21, 2024
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
104 changes: 0 additions & 104 deletions .github/workflows/dockerhub-release-15-6.yml

This file was deleted.

197 changes: 197 additions & 0 deletions .github/workflows/dockerhub-release-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
name: Release all major versions on Dockerhub

on:
push:
branches:
- develop
- release/*
- sam/docker-oriole17
paths:
- '**'
workflow_dispatch:

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix_config: ${{ steps.set-matrix.outputs.matrix_config }}
steps:
- uses: DeterminateSystems/nix-installer-action@main
- name: Checkout Repo
uses: actions/checkout@v3
- name: Generate build matrix
id: set-matrix
run: |
nix run nixpkgs#nushell -- -c 'let versions = (open ansible/vars.yml | get postgres_major)
let matrix = ($versions | each { |ver|
let version = ($ver | str trim)
let dockerfile = $"Dockerfile-($version)"
if ($dockerfile | path exists) {
{
version: $version,
dockerfile: $dockerfile
}
} else {
null
}
} | compact)

let matrix_config = {
include: $matrix
}

$"matrix_config=($matrix_config | to json -r)" | save --append $env.GITHUB_OUTPUT'
build:
needs: prepare
strategy:
matrix: ${{ fromJson(needs.prepare.outputs.matrix_config) }}
runs-on: ubuntu-latest
outputs:
build_args: ${{ steps.args.outputs.result }}
steps:
- uses: actions/checkout@v3
- uses: DeterminateSystems/nix-installer-action@main
- name: Set PostgreSQL version environment variable
run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.version }}" >> $GITHUB_ENV

- id: args
run: |
nix run nixpkgs#nushell -- -c '
open ansible/vars.yml
| items { |key value| {name: $key, item: $value} }
| where { |it| ($it.item | describe) == "string" }
| each { |it| $"($it.name)=($it.item)" }
| str join "\n"
| save --append $env.GITHUB_OUTPUT
'
build_release_image:
needs: [prepare, build]
strategy:
matrix:
postgres: ${{ fromJson(needs.prepare.outputs.matrix_config).include }}
arch: [amd64, arm64]
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'arm-runner' }}
timeout-minutes: 180
steps:
- uses: actions/checkout@v3
- uses: DeterminateSystems/nix-installer-action@main
- run: docker context create builders
- uses: docker/setup-buildx-action@v3
with:
endpoint: builders
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get image tag
id: image
run: |
if [[ "${{ matrix.arch }}" == "arm64" ]]; then
pg_version=$(sudo nix run nixpkgs#nushell -- -c '
let version = "${{ matrix.postgres.version }}"
let release_key = if ($version | str contains "orioledb") {
$"postgresorioledb-17"
} else {
$"postgres($version)"
}
open ansible/vars.yml | get postgres_release | get $release_key | str trim
')
echo "pg_version=supabase/postgres:$pg_version" >> $GITHUB_OUTPUT
else
pg_version=$(nix run nixpkgs#nushell -- -c '
let version = "${{ matrix.postgres.version }}"
let release_key = if ($version | str contains "orioledb") {
$"postgresorioledb-17"
} else {
$"postgres($version)"
}
open ansible/vars.yml | get postgres_release | get $release_key | str trim
')
echo "pg_version=supabase/postgres:$pg_version" >> $GITHUB_OUTPUT
fi
- id: build
uses: docker/build-push-action@v5
with:
push: true
build-args: |
${{ needs.build.outputs.build_args }}
target: production
tags: ${{ steps.image.outputs.pg_version }}_${{ matrix.arch }}
platforms: linux/${{ matrix.arch }}
cache-from: type=gha,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
file: ${{ matrix.postgres.dockerfile }}
merge_manifest:
needs: [prepare, build, build_release_image]
strategy:
matrix:
include: ${{ fromJson(needs.prepare.outputs.matrix_config).include }}
samrose marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: DeterminateSystems/nix-installer-action@main
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get image tag
id: get_version
run: |
nix run nixpkgs#nushell -- -c '
let version = "15"
let release_key = if ($version | str contains "orioledb") {
$"postgres($version | str replace "-" "")"
} else {
$"postgres($version)"
}
let pg_version = (open ansible/vars.yml | get postgres_release | get $release_key | str trim)

$"pg_version=($pg_version)" | save --append $env.GITHUB_OUTPUT
'
- name: Merge multi-arch manifests
run: |
docker buildx imagetools create -t supabase/postgres:${{ steps.get_version.outputs.pg_version }} \
supabase/postgres:${{ steps.get_version.outputs.pg_version }}_amd64 \
supabase/postgres:${{ steps.get_version.outputs.pg_version }}_arm64
get_publish_version:
needs: [prepare, merge_manifest]
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get_versions.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: DeterminateSystems/nix-installer-action@main
- name: Get version
id: get_versions
run: |
nix run nixpkgs#nushell -- -c '
let original_matrix = ${{ needs.prepare.outputs.matrix_config }}
let versions = $original_matrix.include
let processed_versions = ($versions | each { |item|
let version = $item.version
let release_key = if ($version | str contains "orioledb") {
$"postgresorioledb-17"
} else {
$"postgres($version)"
}
let pg_version = (open ansible/vars.yml | get postgres_release | get $release_key | str trim)

# Include both AMD64 and ARM64 architectures
[{version: $pg_version, arch: "amd64"}, {version: $pg_version, arch: "arm64"}]
} | flatten)

let matrix = {include: $processed_versions}
let matrix_json = ($matrix | to json -r)
$"matrix=($matrix_json)" | save --append $env.GITHUB_OUTPUT
'

publish:
needs: get_publish_version
strategy:
matrix: ${{ fromJson(needs.get_publish_version.outputs.matrix) }}
samrose marked this conversation as resolved.
Show resolved Hide resolved
uses: ./.github/workflows/mirror.yml
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
secrets: inherit
13 changes: 10 additions & 3 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ on:
version:
required: true
type: string
arch:
required: true
type: string
workflow_dispatch:
inputs:
version:
description: "Image tag"
required: true
type: string
arch:
description: "Architecture"
required: true
type: string

jobs:
mirror:
Expand All @@ -36,7 +43,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- uses: akhilerm/[email protected]
with:
src: docker.io/supabase/postgres:${{ inputs.version }}
src: docker.io/supabase/postgres:${{ inputs.version }}_${{ inputs.arch }}
dst: |
public.ecr.aws/supabase/postgres:${{ inputs.version }}
ghcr.io/supabase/postgres:${{ inputs.version }}
public.ecr.aws/supabase/postgres:${{ inputs.version }}_${{ inputs.arch }}
ghcr.io/supabase/postgres:${{ inputs.version }}_${{ inputs.arch }}
samrose marked this conversation as resolved.
Show resolved Hide resolved
28 changes: 10 additions & 18 deletions Dockerfile-15
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,14 @@ ARG wal_g_release=2.0.1

FROM ubuntu:focal as base


ENV DEBIAN_FRONTEND=noninteractive \
DEBCONF_NONINTERACTIVE_SEEN=true \
TZ=Etc/UTC

# Pre-configure tzdata before any installations
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone && \
apt-get update && \
apt-get install -y --no-install-recommends tzdata && \
apt-get install -y \
RUN apt update -y && apt install -y \
curl \
gnupg \
lsb-release \
software-properties-common \
wget \
sudo \
git \
&& apt clean && \
rm -rf /var/lib/apt/lists/*
&& apt clean


RUN adduser --system --home /var/lib/postgresql --no-create-home --shell /bin/bash --group --gecos "PostgreSQL administrator" postgres
Expand All @@ -87,11 +75,9 @@ WORKDIR /
RUN mkdir -p /usr/lib/postgresql/bin \
/usr/lib/postgresql/share/postgresql \
/usr/share/postgresql \
# /usr/lib/postgresql/share/postgresql/contrib \
#/usr/lib/postgresql/share/postgresql/timezonesets \
#/usr/lib/postgresql/share/postgresql/tsearch_data \
# /usr/lib/postgresql/share/postgresql/extension \
/var/lib/postgresql \
&& chown -R postgres:postgres /usr/lib/postgresql \
&& chown -R postgres:postgres /var/lib/postgresql \
&& chown -R postgres:postgres /usr/share/postgresql

# Create symbolic links
Expand All @@ -114,6 +100,12 @@ RUN chown -R postgres:postgres /usr/lib/postgresql
RUN ln -sf /usr/lib/postgresql/share/postgresql/timezonesets /usr/share/postgresql/timezonesets


RUN apt-get update && \
apt-get install -y --no-install-recommends tzdata

RUN ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
dpkg-reconfigure --frontend noninteractive tzdata

RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
Expand Down
Loading
Loading