FROM golang:1.9.2

# mattes/migrate
RUN curl -L https://github.com/mattes/migrate/releases/download/v3.0.1/migrate.linux-amd64.tar.gz | tar xvz

ADD ./src/ting /go/src/ting
RUN \
  cd $GOPATH/src/ting && \
  go build -o ting .

COPY migrations /go/migrations
COPY jwt-secret-dev.b64 /go/jwt-secret-dev.b64

EXPOSE 3000
ENTRYPOINT /go/migrate.linux-amd64 -path=migrations/ -database "$DATABASE_URL" up && \
  /go/src/ting/ting -jwt_secret_file=/go/jwt-secret-dev.b64 -logging_format=json
