summaryrefslogtreecommitdiff
path: root/build/postgres
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--build/postgres/Dockerfile6
-rw-r--r--build/postgrest/Dockerfile9
-rwxr-xr-xbuild/postgrest/entrypoint.sh20
-rw-r--r--build/postgrest/postgrest.tar.xzbin0 -> 3648348 bytes
4 files changed, 35 insertions, 0 deletions
diff --git a/build/postgres/Dockerfile b/build/postgres/Dockerfile
new file mode 100644
index 0000000..834fa89
--- /dev/null
+++ b/build/postgres/Dockerfile
@@ -0,0 +1,6 @@
+FROM postgres:16-alpine
+RUN apk add --no-cache make git
+RUN git clone https://github.com/michelp/pgjwt.git /tmp/pgjwt
+WORKDIR /tmp/pgjwt
+RUN make install
+WORKDIR /
diff --git a/build/postgrest/Dockerfile b/build/postgrest/Dockerfile
new file mode 100644
index 0000000..62b8a2e
--- /dev/null
+++ b/build/postgrest/Dockerfile
@@ -0,0 +1,9 @@
+FROM alpine:3.19
+COPY ./postgrest.tar.xz /tmp/postgrest.tar.xz
+RUN tar xJf /tmp/postgrest.tar.xz -C /tmp
+RUN mv /tmp/postgrest /usr/local/bin/postgrest
+RUN rm /tmp/postgrest.tar.xz
+COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh
+CMD ["/usr/local/bin/entrypoint.sh"]
+
+
diff --git a/build/postgrest/entrypoint.sh b/build/postgrest/entrypoint.sh
new file mode 100755
index 0000000..d375769
--- /dev/null
+++ b/build/postgrest/entrypoint.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+mkdir /etc/postgrest.d
+config=/etc/postgrest.d/postgrest.conf
+
+PGRST_DB_URI="postgres://authenticator:postgrest@db:5432/$POSTGRES_DB"
+PGRST_ROLE="rest_anon"
+PGRST_SCHEMA="api"
+
+rm -fr "$config"
+touch "$config"
+printf 'db-uri = "%s"\n' "$PGRST_DB_URI" >> $config
+printf 'db-anon-role = "%s"\n' "$PGRST_ROLE" >> $config
+printf 'db-schemas = "%s"\n' "$PGRST_SCHEMA" >> $config
+printf 'jwt-secret = "%s"\n' "$JWT_SECRET" >> $config
+printf 'jwt-secret-is-base64 = false\n' >> $config
+printf 'server-host = "*"\n' >> $config
+printf 'server-port = 3000\n' >> $config
+
+exec /usr/local/bin/postgrest $config
diff --git a/build/postgrest/postgrest.tar.xz b/build/postgrest/postgrest.tar.xz
new file mode 100644
index 0000000..33c2b2d
--- /dev/null
+++ b/build/postgrest/postgrest.tar.xz
Binary files differ