FROM golang:1.13.3-alpine3.10

RUN apk update
RUN apk upgrade
RUN apk add curl bash git
RUN apk add --no-cache coreutils

# Add wait-for-it.sh so that clients can optionally block on other network dependencies
RUN curl -s -o /wait-for-it.sh https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh && chmod 777 /wait-for-it.sh

RUN go get -u -d github.com/golang-migrate/migrate/cli github.com/lib/pq github.com/hashicorp/go-multierror
RUN go build -tags 'postgres' -o /usr/local/bin/migrate github.com/golang-migrate/migrate/cli

CMD ["migrate"]