dbmate/Dockerfile

42 lines
895 B
Text
Raw Normal View History

# build image
2020-09-27 14:50:30 -07:00
FROM techknowlogick/xgo:go-1.15.x as build
WORKDIR /src
2015-11-25 10:57:58 -08:00
# enable cgo to build sqlite
2015-12-01 17:36:23 -08:00
ENV CGO_ENABLED 1
2015-11-25 10:57:58 -08:00
# install database clients
RUN apt-get update \
&& apt-get install -qq --no-install-recommends \
curl \
mysql-client \
postgresql-client \
sqlite3 \
&& rm -rf /var/lib/apt/lists/*
# golangci-lint
RUN curl -fsSL -o /tmp/lint-install.sh https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
&& chmod +x /tmp/lint-install.sh \
2020-09-27 14:50:30 -07:00
&& /tmp/lint-install.sh -b /usr/local/bin v1.31.0 \
&& rm -f /tmp/lint-install.sh
2015-11-25 10:57:58 -08:00
# download modules
COPY go.* ./
RUN go mod download
2015-11-25 10:57:58 -08:00
# build
COPY . ./
2020-08-08 16:25:13 -07:00
RUN make build
2015-11-25 10:57:58 -08:00
ENTRYPOINT []
CMD ["/bin/bash"]
# runtime image
FROM alpine
RUN apk add --no-cache \
mariadb-client \
postgresql-client \
sqlite
COPY --from=build /src/dist/dbmate-linux-amd64 /usr/local/bin/dbmate
ENTRYPOINT ["dbmate"]