Skip to content

Commit

Permalink
Added Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
jefbarn committed Jul 28, 2021
1 parent 5e747aa commit aefe947
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
56 changes: 56 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
ARG POSTGRES_VERSION=13
ARG PGX_JSON_SCHEMA_VERSION=main

# Use build stage to keep all the souce code out of the final image
FROM postgres:$POSTGRES_VERSION as build
ARG POSTGRES_VERSION
ARG PGX_JSON_SCHEMA_VERSION

# Update postgres and install libraries
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
postgresql-$POSTGRES_VERSION \
postgresql-server-dev-$POSTGRES_VERSION \
build-essential \
curl \
pkg-config \
libssl-dev \
libreadline-dev \
zlib1g-dev \
flex \
bison \
libxml2-dev \
libxslt-dev \
libxml2-utils \
xsltproc \
&& rm -rf /var/lib/apt/lists/*

USER postgres
SHELL ["/bin/bash", "-c"]

# Install Rust
# https://www.rust-lang.org/tools/install
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="~/.cargo/bin:${PATH}"

# Install PGX
WORKDIR $HOME
RUN cargo install cargo-pgx
RUN cargo pgx init --pg$POSTGRES_VERSION /usr/bin/pg_config

# Download this repo
RUN mkdir $HOME/pgx_json_schema
WORKDIR $HOME/pgx_json_schema/
RUN curl -L "https://github.com/jefbarn/pgx_json_schema/archive/${PGX_JSON_SCHEMA_VERSION}.tar.gz" \
| tar -xz --strip-components=1

# Build and install the extension package
RUN cargo pgx package


# Now create the final image
FROM postgres:$POSTGRES_VERSION
ARG POSTGRES_VERSION

COPY --from=build $HOME/pgx_json_schema/target/release/pgx_json_schema-pg$POSTGRES_VERSION /
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install PGX
cargo install cargo-pgx
cargo pgx init

# Download this repo
curl -L 'https://github.com/jefbarn/pgx_json_schema/archive/refs/tags/0.1.0.tar.gz' \
Expand Down Expand Up @@ -64,7 +65,7 @@ error_value | description | details | in
- [ ] Benchmarking
- [ ] Add more schema types like [JTD](https://jsontypedef.com/) and [Avro](https://avro.apache.org/)
- [ ] Support newer JSON Schema drafts
- [ ] Add Dockerfile with installation example
- [x] Add Dockerfile with installation example

### Prior Art
- https://github.com/gavinwahl/postgres-json-schema
Expand Down

0 comments on commit aefe947

Please sign in to comment.