Go v1.11 (#60)

* Go v1.11
* [Go Modules](https://github.com/golang/go/wiki/Modules)
* [GolangCI-Lint](https://github.com/golangci/golangci-lint)
* [Distroless](https://github.com/GoogleContainerTools/distroless) docker image
This commit is contained in:
Adrian Macneil 2018-12-01 22:28:47 -08:00 committed by GitHub
parent abc544b368
commit da3d9525cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 47 additions and 117 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
.DS_Store
.env
/dbmate
/dist
/testdata/db/schema.sql
/vendor

View file

@ -1,5 +1,5 @@
# build image
FROM golang:1.10 as build
FROM golang:1.11 as build
# required to force cgo (for sqlite driver) with cross compile
ENV CGO_ENABLED 1
@ -13,21 +13,17 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*
# development dependencies
RUN curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64 \
&& chmod +x /usr/local/bin/dep
RUN go get gopkg.in/alecthomas/gometalinter.v2 \
&& gometalinter.v2 --install
RUN curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
| sh -s v1.12.3
# copy source files
COPY . /go/src/github.com/amacneil/dbmate
WORKDIR /go/src/github.com/amacneil/dbmate
COPY . /src
WORKDIR /src
# build
RUN make dep install build
RUN make build
# runtime image
FROM debian:stretch-slim
COPY --from=build /go/src/github.com/amacneil/dbmate/dist/dbmate-linux-amd64 \
/usr/local/bin/dbmate
WORKDIR /app
ENTRYPOINT ["/usr/local/bin/dbmate"]
FROM gcr.io/distroless/base
COPY --from=build /src/dist/dbmate-linux-amd64 /dbmate
ENTRYPOINT ["/dbmate"]

63
Gopkg.lock generated
View file

@ -1,63 +0,0 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
name = "github.com/davecgh/go-spew"
packages = ["spew"]
revision = "346938d642f2ec3594ed81d874461961cd0faa76"
version = "v1.1.0"
[[projects]]
branch = "master"
name = "github.com/go-sql-driver/mysql"
packages = ["."]
revision = "2cc627ac8defc45d65066ae98f898166f580f9a4"
[[projects]]
name = "github.com/joho/godotenv"
packages = ["."]
revision = "a79fa1e548e2c689c241d10173efd51e5d689d5b"
version = "v1.2.0"
[[projects]]
branch = "master"
name = "github.com/lib/pq"
packages = [".","oid"]
revision = "19c8e9ad00952ce0c64489b60e8df88bb16dd514"
[[projects]]
name = "github.com/mattn/go-sqlite3"
packages = ["."]
revision = "6c771bb9887719704b210e87e934f08be014bdb1"
version = "v1.6.0"
[[projects]]
name = "github.com/pmezard/go-difflib"
packages = ["difflib"]
revision = "792786c7400a136282c1664665ae0a8db921c6c2"
version = "v1.0.0"
[[projects]]
name = "github.com/stretchr/testify"
packages = ["assert","require"]
revision = "b91bfb9ebec76498946beb6af7c0230c7cc7ba6c"
version = "v1.2.0"
[[projects]]
name = "github.com/urfave/cli"
packages = ["."]
revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1"
version = "v1.20.0"
[[projects]]
name = "google.golang.org/appengine"
packages = ["cloudsql"]
revision = "150dc57a1b433e64154302bdc40b6bb8aefa313a"
version = "v1.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "529ecf990d8fb0e342075bd8e761e40430b28293be2e4fd889d06d12ef978957"
solver-name = "gps-cdcl"
solver-version = 1

View file

@ -1,26 +0,0 @@
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
[[constraint]]
name = "github.com/go-sql-driver/mysql"
branch = "master"
[[constraint]]
name = "github.com/joho/godotenv"
version = "1.2.0"
[[constraint]]
name = "github.com/lib/pq"
branch = "master"
[[constraint]]
name = "github.com/mattn/go-sqlite3"
version = "1.6.0"
[[constraint]]
name = "github.com/stretchr/testify"
version = "1.2.0"
[[constraint]]
name = "github.com/urfave/cli"
version = "1.20.0"

View file

@ -1,30 +1,21 @@
DC := docker-compose
BUILD_FLAGS := -ldflags '-s'
PACKAGES := . ./pkg/...
.PHONY: all
all: dep install test lint build
.PHONY: dep
dep:
dep ensure -vendor-only
.PHONY: install
install:
go install -v $(PACKAGES)
all: test lint build
.PHONY: test
test:
go test -v $(PACKAGES)
go test -v ./...
.PHONY: lint
lint:
gometalinter.v2 $(PACKAGES)
golangci-lint run
.PHONY: wait
wait:
dbmate -e MYSQL_URL wait
dbmate -e POSTGRESQL_URL wait
dist/dbmate-linux-amd64 -e MYSQL_URL wait
dist/dbmate-linux-amd64 -e POSTGRESQL_URL wait
.PHONY: clean
clean:

View file

@ -4,4 +4,4 @@ version: '2.3'
services:
dbmate:
volumes:
- .:/go/src/github.com/amacneil/dbmate
- .:/src

13
go.mod Normal file
View file

@ -0,0 +1,13 @@
module github.com/amacneil/dbmate
require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/go-sql-driver/mysql v0.0.0-20180113200744-2cc627ac8def
github.com/joho/godotenv v1.2.0
github.com/lib/pq v0.0.0-20180123210206-19c8e9ad0095
github.com/mattn/go-sqlite3 v1.6.0
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.2.0
github.com/urfave/cli v1.20.0
google.golang.org/appengine v1.0.0 // indirect
)

18
go.sum Normal file
View file

@ -0,0 +1,18 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-sql-driver/mysql v0.0.0-20180113200744-2cc627ac8def h1:S5Q9hDt/aa5nJp7+qwsNSKi9KIlEoSBaNdjyKS44OAQ=
github.com/go-sql-driver/mysql v0.0.0-20180113200744-2cc627ac8def/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/joho/godotenv v1.2.0 h1:vGTvz69FzUFp+X4/bAkb0j5BoLC+9bpqTWY8mjhA9pc=
github.com/joho/godotenv v1.2.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/lib/pq v0.0.0-20180123210206-19c8e9ad0095 h1:Do4XI4HSm+8jdo6z1Zk0CQDgqoAMwWew3ksTcDDSWiA=
github.com/lib/pq v0.0.0-20180123210206-19c8e9ad0095/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-sqlite3 v1.6.0 h1:TDwTWbeII+88Qy55nWlof0DclgAtI4LqGujkYMzmQII=
github.com/mattn/go-sqlite3 v1.6.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.0 h1:LThGCOvhuJic9Gyd1VBCkhyUXmO8vKaBFvBsJ2k03rg=
github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
google.golang.org/appengine v1.0.0 h1:dN4LljjBKVChsv0XCSI+zbyzdqrkEwX5LQFUMRSGqOc=
google.golang.org/appengine v1.0.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=