11# https://github.com/supabase/pg_jsonschema/blob/master/dockerfiles/db/Dockerfile
2- FROM postgres:16 as base
2+ FROM alpine:3.19 AS downloader
3+ RUN apk add --no-cache git
4+ RUN git clone https://github.com/supabase/pg_jsonschema.git --depth 1
5+
6+ FROM postgres:16
37RUN apt-get update
48
59ENV build_deps ca-certificates \
@@ -15,10 +19,10 @@ ENV build_deps ca-certificates \
1519RUN apt-get install -y --no-install-recommends $build_deps pkg-config cmake
1620
1721WORKDIR /home/supa
18-
22+ COPY --from=downloader /pg_jsonschema ./
1923ENV HOME=/home/supa \
2024 PATH=/home/supa/.cargo/bin:$PATH
21- RUN chown postgres:postgres /home/supa
25+ RUN chown postgres:postgres /home/supa -R
2226USER postgres
2327
2428RUN \
@@ -42,16 +46,3 @@ RUN chown -R postgres:postgres /usr/share/postgresql/16/extension
4246RUN chown -R postgres:postgres /usr/lib/postgresql/16/lib
4347
4448USER postgres
45-
46- # Script to detect whether the database has finished initializing
47- COPY ["true_isready.sh" , "/usr/local/bin/" ]
48- COPY ["database scripts/00_dump.sql" , "database scripts/0[2345]_*.sql" , "database scripts/json_schema_extension.sql" , "/docker-entrypoint-initdb.d/" ]
49-
50- # Install https://github.com/gavinwahl/postgres-json-schema/
51- # extension that allows validation of jsonb fields against jsonschema
52- COPY ["install_postgres_json_schema_extension.sh" , "install_postgres_json_schema_extension.sh" ]
53- RUN chmod u+x install_postgres_json_schema_extension.sh
54- RUN ./install_postgres_json_schema_extension.sh
55-
56- FROM base AS demo
57- COPY ["database scripts/demo_db.sql" , "/docker-entrypoint-initdb.d/" ]
0 commit comments