ARG PG_MAJOR_VERSION=13

FROM postgres:$PG_MAJOR_VERSION

# An ARG declared before a FROM is outside of a build stage, so it can’t be
# used in any instruction after a FROM. We need to declare it again.
ARG PG_MAJOR_VERSION

RUN apt-get update && apt-get install -y \
    gawk \
    gcc \
    make \
    postgresql-server-dev-$PG_MAJOR_VERSION \
    postgresql-plpython3-$PG_MAJOR_VERSION \
    python3-pip \
 && rm -rf /var/lib/apt/lists/*

# Install the extension
WORKDIR /src
COPY . .
RUN pip3 install -r requirements.txt
RUN make clean && make && make install

