FROM postgres:{{postgresVersion}}
{{#if authorName}}LABEL maintainer="{{authorName}}{{#if authorEmail}} <{{authorEmail}}>{{/if}}"{{/if}}

RUN apt-get update \
      && apt-get install -y --no-install-recommends \
           postgresql \
      && rm -rf /var/lib/apt/lists/*

# Mount this volume to help loading/exporting dumps
RUN mkdir /workdir
VOLUME /workdir

ENV PGPASSFILE=/.pgpass
COPY postgres/.pgpass /.pgpass
RUN chmod 600 /.pgpass

# Fix permissions to match host user
RUN usermod -u ${HOST_UID:-1000} postgres && groupmod -g ${HOST_GID:-1000} postgres
RUN chown postgres /.pgpass
