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

Build packages for postgres extensions #90

Merged
merged 17 commits into from
Feb 8, 2023
Merged

Build packages for postgres extensions #90

merged 17 commits into from
Feb 8, 2023

Conversation

sjmiller609
Copy link
Contributor

@sjmiller609 sjmiller609 commented Feb 7, 2023

I'm looking at how postgres ML is doing packaging:

They are building with pgx inside docker and then copying a .deb package out from the container, which can be installed on ubuntu.

At the moment, we do not have an APT repository. I think we ought to build and upload our extensions to an APT repository, then install from there into our postgres image, that way our extensions and other extensions are being installed in the same way. For this PR, we are just building the extension before doing the docker build of postgres, then using COPY in the dockerfile to copy the .deb into our postgres image and install it.

@sjmiller609 sjmiller609 changed the title Extension is building in a container Build packages for postgres extensions Feb 7, 2023
@@ -0,0 +1,54 @@
ARG UBUNTU_VERSION=22.04
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is imitating this dockerfile, less the not applicable parts

https://github.com/postgresml/postgresml/blob/master/pgml-extension/Dockerfile

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this file is to build an .deb (package) file for ubuntu with a PGX extension in it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will all of our CoreDB postgres images be ubuntu based then, or just the images that contain extensions which we author?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have to pick one distro to do first. For example, postgres ML is only doing ubuntu or inside a container (or build from source): https://postgresml.org/user_guides/setup/v2/installation/#install-the-extension

@@ -0,0 +1,29 @@
#!/bin/bash
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses a container to build the extension, and outputs to the local filesystem the .deb package

@@ -1,7 +1,51 @@
FROM postgres:15.1
FROM ubuntu:22.04
Copy link
Contributor Author

@sjmiller609 sjmiller609 Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we built on ubuntu, the shared libraries don't work unless we also run on Ubuntu. For example, I had an issue before I switched this to Ubuntu with an error

postgres=# CREATE EXTENSION pgx_pgmq;
ERROR:  could not load library "/usr/lib/postgresql/15/lib/pgx_pgmq.so": /lib/aarch64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /usr/lib/postgresql/15/lib/pgx_pgmq.so)

And that's because the distro has different versions of system software available.

We kind of have to pick one distro to support first.

@@ -0,0 +1,340 @@
#!/usr/bin/env bash
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +88 to +97
- name: Run pre-build hooks
shell: bash
run: |
cd ${{ inputs.docker_directory }}
if [[ -f pre-build-hook.sh ]]; then
echo "detected pre-build hook, running"
/bin/bash pre-build-hook.sh
else
echo "no pre build hook detected"
fi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get the extension installed into the postgres container, we have a script that builds the extension, and puts the package into a directory "extensions" in the postgres directory before doing the build of the postgres image.

I think we ought to instead publish our packages and just pull them in in the docker build over the internet from our repository instead of doing this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

publish the pgx extension as a crate, then pull from crates.io and install?

as opposed to cloning the repo, then pushing to crates.io and quay.io at same time (or in sequence)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean publish to an APT repository the .deb package. Seems to me like that's the best way to package and distribute extensions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I mean i'm imagining our workflow will build and publish to our APT repository all our extensions (and I think we don't need to publish extensions to crates.io). So that's another artifact type.

@@ -0,0 +1,53 @@
#!/bin/bash
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjmiller609 sjmiller609 marked this pull request as ready for review February 8, 2023 00:04
@@ -180,7 +180,7 @@ TODO:
Delete a message with id `1` from queue named `my_queue`.
```sql
pgmq=# select pgmq_delete('my_queue', 1);
pgmq_delete
pgmq_delete
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my editor is automatically removing trailing whitespaces

@sjmiller609 sjmiller609 merged commit 5a4423b into main Feb 8, 2023
@sjmiller609 sjmiller609 deleted the cor-225 branch February 8, 2023 15:53
sjmiller609 pushed a commit that referenced this pull request Dec 5, 2023
* remove sleep on success

Can we remove this? I dont think we need to sleep after successfully processing messaging, or does this serve some other purpose?

* remove unused code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants