-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e6bace
commit d028b04
Showing
4 changed files
with
133 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,75 @@ | ||
FROM debian:bullseye | ||
|
||
ARG PG_MAJOR_VER | ||
ARG PG_MAJOR_VERSION | ||
ARG PLPRQL_VERSION | ||
|
||
# Install PostgreSQL | ||
RUN apt-get update | ||
RUN apt-get install -y wget gnupg | ||
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main" >> /etc/apt/sources.list.d/pgdg.list | ||
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - | ||
RUN apt-get update | ||
RUN apt-get install -y build-essential postgresql-server-dev-${PG_MAJOR_VER} postgresql-${PG_MAJOR_VER} | ||
RUN apt-get install -y build-essential postgresql-server-dev-${PG_MAJOR_VERSION} postgresql-${PG_MAJOR_VERSION} | ||
|
||
# Install utilities | ||
RUN apt-get install -y jq git ruby | ||
|
||
# Install fpm for the creation of the .deb file, | ||
# and install toml so TOML files can be parsed later | ||
RUN gem install --no-document fpm toml | ||
|
||
# Install rust | ||
RUN apt-get install -y curl pkg-config | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
ENV PATH="/root/.cargo/bin:${PATH}" | ||
|
||
RUN cargo install --locked cargo-pgrx --version 0.11.2 | ||
RUN cargo pgrx init --pg${PG_MAJOR_VER} /usr/bin/pg_config | ||
# Prepare source directory | ||
COPY ./ /src | ||
WORKDIR /src/plprql | ||
|
||
# Install pgrx using the version in Cargo.toml | ||
RUN PGRX_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="pgrx")|.version') && \ | ||
cargo install cargo-pgrx --force --version "${PGRX_VERSION}" | ||
RUN cargo pgrx init --pg${PG_MAJOR_VERSION} $(which pg_config) | ||
|
||
# Package the extension. This command will create all the files necessary to package up in a .deb file. | ||
# We know the directory in which this command will create the files, and we save it in the RELEASE_DIR env variable. | ||
RUN cargo pgrx package --features pg${PG_MAJOR_VERSION} | ||
ENV RELEASE_DIR /src/target/release/plprql-pg${PG_MAJOR_VERSION} | ||
|
||
# Create the directory for the outgoing .deb package | ||
RUN mkdir /artifacts && chmod 777 /artifacts | ||
|
||
# Create the --before-install script | ||
RUN echo $'#!/bin/bash\n\ | ||
\n\ | ||
if ! id -u postgres 2>&1 > /dev/null; then\n\ | ||
echo "[!] User 'postgres' does not exist. Have the official Postgres packages been installed yet?"\n\ | ||
exit 1\n\ | ||
fi' >> /tmp/before-install.sh | ||
|
||
# Package everything up based on whatever's in RELEASE_DIR, and send the resulting | ||
# .deb file to the /artifact directory. We don't check if PostgreSQL is installed | ||
# (e.g. via -d "postgresql-${PG_MAJOR_VERSION}") because it could have been compiled | ||
# from source or installed in a myriad of other ways. We simply check for the postgres | ||
# user and let the install fail and hard if the required directories do not exist. | ||
RUN DEB_FILENAME="plprql-${PLPRQL_VERSION}-postgresql-${PG_MAJOR_VERSION}-debian-$(dpkg --print-architecture).deb" && \ | ||
cd ${RELEASE_DIR} && fpm \ | ||
-s dir \ | ||
-t deb \ | ||
-n plprql \ | ||
-m 'Kasper Marstal, kaspermarstal@gmail.com' \ | ||
--description 'PL/PRQL is a PostgreSQL extension that lets you write functions with PRQL.' \ | ||
-v ${PLPRQL_VERSION} \ | ||
--url 'https://github.com/kaspermarstal/plprql' \ | ||
--license 'Apache 2.0 License' \ | ||
--category 'Databases' \ | ||
--deb-no-default-config-files \ | ||
--before-install /tmp/before-install.sh \ | ||
-p /artifacts/$DEB_FILENAME \ | ||
--deb-user postgres \ | ||
--deb-group postgres \ | ||
-a native \ | ||
. | ||
|
||
COPY ./ /plprql | ||
WORKDIR /plprql | ||
RUN cargo pgrx install --release -c "/usr/bin/pg_config" | ||
RUN ls /artifacts |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters