8000 publish docker images/image updates for major versions by samrose · Pull Request #1372 · supabase/postgres · GitHub
[go: up one dir, main page]

Skip to content

publish docker images/image updates for major versions #1372

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

Merged
merged 97 commits into from
Dec 21, 2024
Merged
Changes from 1 commit
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
Next Next commit
feat: orioledb-17 Docker image and publish workflow
  • Loading branch information
samrose committed Dec 9, 2024
commit c37f69bfbf65a2ea906f4615caf4e8d636ae7303
241 changes: 241 additions & 0 deletions Dockerfile-17-orioledb
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
# syntax=docker/dockerfile:1.6
ARG postgresql_major=17-orioledb
ARG postgresql_release=${postgresql_major}.1

# Bump default build arg to build a package from source
# Bump vars.yml to specify runtime package version
ARG sfcgal_release=1.3.10
ARG postgis_release=3.3.2
ARG pgrouting_release=3.4.1
ARG pgtap_release=1.2.0
ARG pg_cron_release=1.6.2
ARG pgaudit_release=1.7.0
ARG pgjwt_release=9742dab1b2f297ad3811120db7b21451bca2d3c9
ARG pgsql_http_release=1.5.0
ARG plpgsql_check_release=2.2.5
ARG pg_safeupdate_release=1.4
ARG timescaledb_release=2.9.1
ARG wal2json_release=2_5
ARG pljava_release=1.6.4
ARG plv8_release=3.1.5
ARG pg_plan_filter_release=5081a7b5cb890876e67d8e7486b6a64c38c9a492
ARG pg_net_release=0.7.1
ARG rum_release=1.3.13
ARG pg_hashids_release=cd0e1b31d52b394a0df64079406a14a4f7387cd6
ARG libsodium_release=1.0.18
ARG pgsodium_release=3.1.6
ARG pg_graphql_release=1.5.1
ARG pg_stat_monitor_release=1.1.1
ARG pg_jsonschema_release=0.1.4
ARG pg_repack_release=1.4.8
ARG vault_release=0.2.8
ARG groonga_release=12.0.8
ARG pgroonga_release=2.4.0
ARG wrappers_release=0.3.0
ARG hypopg_release=1.3.1
ARG pgvector_release=0.4.0
ARG pg_tle_release=1.3.2
ARG index_advisor_release=0.2.0
ARG supautils_release=2.2.0
ARG wal_g_release=2.0.1

FROM ubuntu:focal as base

RUN apt update -y && apt install -y \
curl \
gnupg \
lsb-release \
software-properties-common \
wget \
sudo \
tree \
&& apt clean


RUN adduser --system --home /var/lib/postgresql --no-create-home --shell /bin/bash --group --gecos "PostgreSQL administrator" postgres
RUN adduser --system --no-create-home --shell /bin/bash --group wal-g
RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux \
--init none \
--no-confirm \
--extra-conf "substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com" \
--extra-conf "trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="

ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin"

COPY . /nixpg

WORKDIR /nixpg

RUN nix profile install .#psql_orioledb-17/bin



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 \
&& chown -R postgres:postgres /usr/lib/postgresql \
&& chown -R postgres:postgres /usr/share/postgresql

# Create symbolic links
RUN ln -s /nix/var/nix/profiles/default/bin/* /usr/lib/postgresql/bin/ \
&& ln -s /nix/var/nix/profiles/default/bin/* /usr/bin/ \
&& chown -R postgres:postgres /usr/bin

# Create symbolic links for PostgreSQL shares
RUN ln -s /nix/var/nix/profiles/default/share/postgresql/* /usr/lib/postgresql/share/postgresql/
RUN ln -s /nix/var/nix/profiles/default/share/postgresql/* /usr/share/postgresql/
RUN chown -R postgres:postgres /usr/lib/postgresql/share/postgresql/
RUN chown -R postgres:postgres /usr/share/postgresql/
# Create symbolic links for contrib directory
RUN tree /nix > /tmp/tree.txt && cat /tmp/tree.txt && cat /tmp/tree.txt >&2


# RUN mkdir -p /usr/lib/postgresql/share/postgresql/contrib \
# && find /nix/var/nix/profiles/default/share/postgresql/contrib/ -mindepth 1 -type d -exec sh -c 'for dir do ln -s "$dir" "/usr/lib/postgresql/share/postgresql/contrib/$(basename "$dir")"; done' sh {} + \
# && chown -R postgres:postgres /usr/lib/postgresql/share/postgresql/contrib/

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 \
checkinstall \
cmake

ENV PGDATA=/var/lib/postgresql/data

####################
# setup-wal-g.yml
####################
FROM base as walg
ARG wal_g_release
# ADD "https://github.com/wal-g/wal-g/releases/download/v${wal_g_release}/wal-g-pg-ubuntu-20.04-${TARGETARCH}.tar.gz" /tmp/wal-g.tar.gz
RUN arch=$([ "$TARGETARCH" = "arm64" ] && echo "aarch64" || echo "$TARGETARCH") && \
apt-get update && apt-get install -y --no-install-recommends curl && \
curl -kL "https://github.com/wal-g/wal-g/releases/download/v${wal_g_release}/wal-g-pg-ubuntu-20.04-aarch64.tar.gz" -o /tmp/wal-g.tar.gz && \
tar -xvf /tmp/wal-g.tar.gz -C /tmp && \
rm -rf /tmp/wal-g.tar.gz && \
mv /tmp/wal-g-pg-ubuntu*20.04-aarch64 /tmp/wal-g

# ####################
# # Download gosu for easy step-down from root
# ####################
FROM base as gosu
ARG TARGETARCH
# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gnupg \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Download binary
ARG GOSU_VERSION=1.16
ARG GOSU_GPG_KEY=B42F6819007F00F88E364FD4036A9C25BF357DD4
ADD https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$TARGETARCH \
/usr/local/bin/gosu
ADD https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$TARGETARCH.asc \
/usr/local/bin/gosu.asc
# Verify checksum
RUN gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys $GOSU_GPG_KEY && \
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu && \
gpgconf --kill all && \
chmod +x /usr/local/bin/gosu

# ####################
# # Build final image
# ####################
FROM gosu as production
RUN id postgres || (echo "postgres user does not exist" && exit 1)
# # Setup extensions
COPY --from=walg /tmp/wal-g /usr/local/bin/

# # Initialise configs
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf
COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_hba.conf.j2 /etc/postgresql/pg_hba.conf
COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_ident.conf.j2 /etc/postgresql/pg_ident.conf
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout-log.conf /etc/postgresql/logging.conf
COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf
COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts
COPY --chown=postgres:postgres ansible/files/pgsodium_getkey_urandom.sh.j2 /usr/lib/postgresql/bin/pgsodium_getkey.sh
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_read_replica.conf.j2 /etc/postgresql-custom/read-replica.conf
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/wal-g.conf
COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /home/postgres/wal_fetch.sh
COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh

RUN sed -i \
-e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \
-e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \
-e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \
-e "s|#include = '/etc/postgresql-custom/wal-g.conf'|include = '/etc/postgresql-custom/wal-g.conf'|g" /etc/postgresql/postgresql.conf && \
echo "cron.database_name = 'postgres'" >> /etc/postgresql/postgresql.conf && \
#echo "pljava.libjvm_location = '/usr/lib/jvm/java-11-openjdk-${TARGETARCH}/lib/server/libjvm.so'" >> /etc/postgresql/postgresql.conf && \
echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
echo 'auto_explain.log_min_duration = 10s' >> /etc/postgresql/postgresql.conf && \
usermod -aG postgres wal-g && \
mkdir -p /etc/postgresql-custom && \
chown postgres:postgres /etc/postgresql-custom

# Remove items from postgresql.conf
RUN sed -i 's/ timescaledb,//g;' "/etc/postgresql/postgresql.conf"
#as of pg 16.4 + this db_user_namespace totally deprecated and will break the server if setting is present
RUN sed -i 's/db_user_namespace = off/#db_user_namespace = off/g;' "/etc/postgresql/postgresql.conf"
RUN sed -i 's/ timescaledb,//g; s/ plv8,//g; s/ postgis,//g; s/ pgrouting,//g' "/etc/postgresql-custom/supautils.conf"
RUN sed -i 's/\(shared_preload_libraries.*\)'\''\(.*\)$/\1, orioledb'\''\2/' "/etc/postgresql/postgresql.conf"
RUN echo "default_table_access_method = 'orioledb'" >> "/etc/postgresql/postgresql.conf"



# # Include schema migrations
COPY migrations/db /docker-entrypoint-initdb.d/
COPY ansible/files/pgbouncer_config/pgbouncer_auth_schema.sql /docker-entrypoint-initdb.d/init-scripts/00-schema.sql
COPY ansible/files/stat_extension.sql /docker-entrypoint-initdb.d/migrations/00-extension.sql
# Enable orioledb extension first
RUN echo "CREATE EXTENSION orioledb;" > /docker-entrypoint-initdb.d/init-scripts/00-pre-init.sql && \
chown postgres:postgres /docker-entrypoint-initdb.d/init-scripts/00-pre-init.sql

# # Add upstream entrypoint script
COPY --from=gosu /usr/local/bin/gosu /usr/local/bin/gosu
ADD --chmod=0755 \
https://github.com/docker-library/postgres/raw/master/17/bullseye/docker-entrypoint.sh \
/usr/local/bin/

RUN mkdir -p /var/run/postgresql && chown postgres:postgres /var/run/postgresql

ENTRYPOINT ["docker-entrypoint.sh"]

HEALTHCHECK --interval=2s --timeout=2s --retries=10 CMD pg_isready -U postgres -h localhost
STOPSIGNAL SIGINT
EXPOSE 5432

ENV POSTGRES_HOST=/var/run/postgresql
ENV POSTGRES_USER=supabase_admin
ENV POSTGRES_DB=postgres
ENV POSTGRES_INITDB_ARGS="--allow-group-access --locale-provider=icu --encoding=UTF-8 --icu-locale=en_US.UTF-8"
RUN apt-get update && apt-get install -y --no-install-recommends \
locales \
&& rm -rf /var/lib/apt/lists/* && \
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
&& localedef -i C -c -f UTF-8 -A /usr/share/locale/locale.alias C.UTF-8
RUN echo "C.UTF-8 UTF-8" > /etc/locale.gen && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV LC_CTYPE=C.UTF-8
ENV LC_COLLATE=C.UTF-8
ENV LOCALE_ARCHIVE /usr/lib/locale/locale-archive
CMD ["postgres", "-D", "/etc/postgresql"]
0