dbmate/Dockerfile

43 lines
850 B
Text
Raw Normal View History

2020-11-02 20:22:59 +13:00
# development image
2021-02-22 11:26:35 -08:00
FROM techknowlogick/xgo:go-1.16.x as dev
WORKDIR /src
2020-11-02 20:22:59 +13:00
ENV GOCACHE /src/.cache/go-build
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
2021-04-07 13:51:50 -07:00
RUN curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
| sh -s -- -b /usr/local/bin v1.39.0
2015-11-25 10:57:58 -08:00
# download modules
COPY go.* ./
RUN go mod download
2015-11-25 10:57:58 -08:00
ENTRYPOINT []
CMD ["/bin/bash"]
2020-11-02 20:22:59 +13:00
# build stage
FROM dev as build
COPY . ./
RUN make build
# release stage
FROM alpine as release
RUN apk add --no-cache \
2020-11-02 20:22:59 +13:00
mariadb-client \
postgresql-client \
sqlite \
tzdata
COPY --from=build /src/dist/dbmate-linux-amd64 /usr/local/bin/dbmate
ENTRYPOINT ["dbmate"]