2018-09-17 11:04:07 +08:00
|
|
|
FROM golang:1.11-rc-alpine as build
|
|
|
|
|
2018-09-17 11:59:35 +08:00
|
|
|
# args
|
2018-09-17 11:53:39 +08:00
|
|
|
ARG version="3.5.2"
|
|
|
|
ARG databases="cassandra clickhouse cockroachdb crate mongodb mysql neo4j postgres ql redshift shell spanner sqlite3 stub testing"
|
|
|
|
|
2018-09-17 11:59:35 +08:00
|
|
|
# dependencies
|
2018-09-17 11:53:39 +08:00
|
|
|
RUN apk add --no-cache git ca-certificates
|
2018-09-17 11:04:07 +08:00
|
|
|
|
2018-09-17 11:59:35 +08:00
|
|
|
# build tools: dep
|
2018-09-17 11:04:07 +08:00
|
|
|
RUN wget -O /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 && chmod +x /usr/local/bin/dep
|
|
|
|
|
2018-09-17 11:59:35 +08:00
|
|
|
# source
|
2018-09-17 11:53:39 +08:00
|
|
|
RUN git clone https://github.com/golang-migrate/migrate -b "v${version}" $GOPATH/src/github.com/golang-migrate/migrate
|
|
|
|
WORKDIR $GOPATH/src/github.com/golang-migrate/migrate
|
|
|
|
RUN git checkout -b "v${version}"
|
|
|
|
|
2018-09-17 11:59:35 +08:00
|
|
|
# dependencies
|
2018-09-17 11:04:07 +08:00
|
|
|
WORKDIR $GOPATH/src/github.com/golang-migrate/migrate/cli
|
|
|
|
RUN dep ensure
|
2018-09-17 11:59:35 +08:00
|
|
|
|
|
|
|
# build
|
|
|
|
ENV CGO_ENABLED=0
|
|
|
|
ENV GOOS=linux
|
|
|
|
ENV GOARCH=amd64
|
|
|
|
RUN go build -ldflags "-s -w" -tags '${databases}' -o /migrate
|
2018-09-17 11:04:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
FROM scratch
|
|
|
|
|
2018-09-17 12:05:18 +08:00
|
|
|
ARG version
|
|
|
|
|
2018-09-17 11:53:39 +08:00
|
|
|
# labels
|
|
|
|
LABEL org.label-schema.vcs-url="https://github.com/productionwentdown/migrate"
|
|
|
|
LABEL org.label-schema.version=${version}
|
|
|
|
LABEL org.label-schema.schema-version="1.0"
|
|
|
|
|
2018-09-17 11:59:35 +08:00
|
|
|
# copy binary and ca certs
|
2018-09-17 11:41:25 +08:00
|
|
|
COPY --from=build /migrate /migrate
|
2018-09-17 11:53:39 +08:00
|
|
|
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
2018-09-17 11:04:07 +08:00
|
|
|
|
2018-09-17 11:59:35 +08:00
|
|
|
WORKDIR /
|
|
|
|
|
2018-09-17 11:41:25 +08:00
|
|
|
ENTRYPOINT ["/migrate"]
|