Use make for docker builds so all releases use the same db and source drivers

This commit is contained in:
Dale Hui
2020-08-03 16:28:46 -07:00
parent 6066a404ba
commit 63ce4b0ab8
3 changed files with 7 additions and 7 deletions
-1
View File
@@ -2,7 +2,6 @@
FAQ.md
README.md
LICENSE
Makefile
.gitignore
.travis.yml
CONTRIBUTING.md
+2 -4
View File
@@ -1,13 +1,11 @@
FROM golang:1.14-alpine3.12 AS builder
ARG VERSION
RUN apk add --no-cache git gcc musl-dev
RUN apk add --no-cache git gcc musl-dev make
WORKDIR /go/src/github.com/golang-migrate/migrate
ENV GO111MODULE=on
ENV DATABASES="postgres mysql redshift cassandra spanner cockroachdb clickhouse mongodb sqlserver firebird sqlite3 neo4j"
ENV SOURCES="file go_bindata github github_ee aws_s3 google_cloud_storage godoc_vfs gitlab"
COPY go.mod go.sum ./
@@ -15,7 +13,7 @@ RUN go mod download
COPY . ./
RUN go build -a -o build/migrate.linux-386 -ldflags="-s -w -X main.Version=${VERSION}" -tags "$DATABASES $SOURCES" ./cmd/migrate
RUN make build-docker
FROM alpine:3.12
+5 -2
View File
@@ -9,6 +9,9 @@ COVERAGE_DIR ?= .coverage
build:
CGO_ENABLED=0 go build -ldflags='-X main.Version=$(VERSION)' -tags '$(DATABASE) $(SOURCE)' ./cmd/migrate
build-docker:
CGO_ENABLED=0 go build -a -o build/migrate.linux-386 -ldflags="-s -w -X main.Version=${VERSION}" -tags "$(DATABASE) $(SOURCE)" ./cmd/migrate
build-cli: clean
-mkdir ./cli/build
cd ./cmd/migrate && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o ../../cli/build/migrate.linux-amd64 -ldflags='-X main.Version=$(VERSION) -extldflags "-static"' -tags '$(DATABASE) $(SOURCE)' .
@@ -102,10 +105,10 @@ define external_deps
endef
.PHONY: build build-cli clean test-short test test-with-flags html-coverage \
.PHONY: build build-docker build-cli clean test-short test test-with-flags html-coverage \
restore-import-paths rewrite-import-paths list-external-deps release \
docs kill-docs open-docs kill-orphaned-docker-containers
SHELL = /bin/bash
SHELL = /bin/sh
RAND = $(shell echo $$RANDOM)