##### PostgresQL migrations using Sqitch #####

# https://github.com/debuerreotype/docker-debian-artifacts/issues/134
FROM debian:bullseye-slim

# Update apt-get cache
RUN apt-get update

# Install Sqitch, Postgres client, and nc (for entrypoint)
RUN DEBIAN_FRONTEND=noninteractive \
    apt-get install -y --no-install-recommends \
    sqitch \
    libpq5 \
    netcat

RUN mkdir sqitch
WORKDIR sqitch

COPY sqitch.conf ./
COPY migrations migrations

ENV PGDB_HOST PGDB_NAME PGDB_PASS PGDB_PORT PGDB_USER

ENTRYPOINT ["./migrations/migration_entrypoint.sh"]
