Skip to content

Commit

Permalink
build: Add dockerfile (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspermarstal authored Oct 13, 2024
1 parent a5edaf8 commit ef06319
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
-t "plprql-$PLPRQL_VERSION-pg-${{ matrix.pg }}-${{ matrix.os.distribution }}-${{ matrix.os.release }}" \
-f ".github/docker/Dockerfile.${{ matrix.os.distribution }}" \
.
- name: Extract .deb
- name: Copy .deb from docker image to runner
run: |
CONTAINER_ID=$(docker create plprql-$PLPRQL_VERSION-pg-${{ matrix.pg }}-${{ matrix.os.distribution }}-${{ matrix.os.release }})
docker cp $CONTAINER_ID:/artifacts /home/runner
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ For more information on PRQL, visit the PRQL [website](https://prql-lang.org/),
## Getting Started

You can install the PL/PRQL extension in three ways:
You can install the PL/PRQL extension in four ways:

- [Install Deb File](#install-deb-file): Download .deb file from releases page.
- [Install From Source](#install-from-source): Clone the repository and build the extension on your own machine.
- [Run Dockerfile](#run-dockerfile): Build a docker image with PostgreSQL and the extension.
- [Run Shell Script](#run-shell-script): Download and run a shell script builds the extension on your own machine for you.


The instruction assume you use Ubuntu or Debian.

### Install Deb File
Expand Down Expand Up @@ -167,6 +169,25 @@ PL/PRQL is built on top of the [pgrx](https://github.com/pgcentralfoundation/pgr
$$ language plprql
psql> select match_stats(1);
```

### Run Dockerfile

The `docker/plprql.Dockerfile` builds the `postgres:16-bookworm` docker image with the extension installed. You run this Dockerfile on your own machine with the following commands:

```cmd
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/kaspermarstal/plprql/main/docker/plprql.Dockerfile > plprql.Dockerfile
docker build --tag 'plprql' . -f plprql.Dockerfile
```

The dockerfile downloads a .deb file from the releases page and installs it into the official `postgres:16-bookworm` image.

You can quickly test that the extension is installed and works as expected:

```cmd
CONTAINER_ID=$(docker run -d -e POSTGRES_HOST_AUTH_METHOD=trust plprql)
docker exec $CONTAINER_ID psql -U postgres -c "create extension plprql;"
docker exec $CONTAINER_ID psql -U postgres -c "select prql_to_sql1('from table')"
```

### Run Shell Script
Run the following command to download and execute the shell script in [scripts/install.sh](scripts/install.sh):
Expand Down
10 changes: 10 additions & 0 deletions docker/plprql.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM postgres:16-bookworm AS builder

RUN apt-get update && apt-get install -y wget
RUN wget -P /tmp https://github.com/kaspermarstal/plprql/releases/download/v1.0.0/plprql-1.0.0-postgresql-16-debian-bookworm-amd64.deb

FROM postgres:16-bookworm

COPY --from=builder /tmp/plprql-1.0.0-postgresql-16-debian-bookworm-amd64.deb /tmp/plprql-1.0.0-postgresql-16-debian-bookworm-amd64.deb
RUN dpkg -i /tmp/plprql-1.0.0-postgresql-16-debian-bookworm-amd64.deb && \
rm /tmp/plprql-1.0.0-postgresql-16-debian-bookworm-amd64.deb

0 comments on commit ef06319

Please sign in to comment.