dbmate/Dockerfile

44 lines
946 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
RUN curl -fsSL -o /tmp/lint-install.sh https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
&& chmod +x /tmp/lint-install.sh \
2021-02-22 11:26:35 -08:00
&& /tmp/lint-install.sh -b /usr/local/bin v1.37.1 \
&& 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
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
COPY --from=build /src/dist/dbmate-linux-amd64 /usr/local/bin/dbmate
ENTRYPOINT ["dbmate"]