dbmate/Dockerfile
Adrian Macneil d855ee1ada
Add dump command (#23)
Adds `dbmate dump` command to write the database schema to a file.

The intent is for this file to be checked in to the codebase, similar to Rails' `schema.rb` (or `structure.sql`) file. This allows developers to share a single file documenting the database schema, and makes it considerably easier to review PRs which add (or change) migrations.

The existing `up`, `migrate`, and `rollback` commands will automatically trigger a schema dump, unless `--no-dump-schema` is passed.

Closes https://github.com/amacneil/dbmate/issues/5
2018-01-22 20:38:40 -08:00

30 lines
705 B
Docker

# build image
FROM golang:1.9 as build
# required to force cgo (for sqlite driver) with cross compile
ENV CGO_ENABLED 1
# install database clients
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
mysql-client \
postgresql-client \
sqlite3 \
&& rm -rf /var/lib/apt/lists/*
# development dependencies
RUN go get \
github.com/golang/lint/golint \
github.com/kisielk/errcheck
# copy source files
COPY . $GOPATH/src/github.com/amacneil/dbmate
WORKDIR $GOPATH/src/github.com/amacneil/dbmate
# build
RUN go build -ldflags '-s' -o /go/bin/dbmate ./cmd/dbmate
# runtime image
FROM debian:stretch-slim
COPY --from=build /go/bin/dbmate /usr/local/bin/dbmate
ENTRYPOINT ["dbmate"]