Skip to content

Commit

Permalink
Bump to build-tools 1.6.0 (#993)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Jul 17, 2018
1 parent 4c9feb0 commit 8d88658
Show file tree
Hide file tree
Showing 20 changed files with 248 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
name: ddev tests
no_output_timeout: "40m"

- run: make -s gometalinter
- run: make -s staticrequired

- run:
command: bin/linux/ddev version
Expand Down
25 changes: 1 addition & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ setup:
@mkdir -p .go/src/$(PKG) .go/pkg .go/bin .go/std/linux

# Required static analysis targets used in circleci - these cause fail if they don't work
staticrequired: gometalinter
staticrequired: gometalinter golangci-lint

windows_install: windows bin/windows/windows_amd64/sudo.exe bin/windows/windows_amd64/sudo_license.txt
makensis -DVERSION=$(VERSION) winpkg/ddev.nsi # brew install makensis, apt-get install nsis, or install on Windows
Expand All @@ -97,26 +97,3 @@ bin/windows/windows_amd64/sudo.exe bin/windows/windows_amd64/sudo_license.txt:
curl -sSL -o /tmp/sudo.zip -O https://github.com/mattn/sudo/releases/download/$(WINDOWS_SUDO_VERSION)/sudo-x86_64.zip
unzip -o -d $(PWD)/bin/windows/windows_amd64 /tmp/sudo.zip
curl -sSL -o $(PWD)/bin/windows/windows_amd64/sudo_license.txt https://raw.githubusercontent.com/mattn/sudo/master/LICENSE


# This build override puts the "/" on the front of the -v statements, which
# solves problems on Docker toolbox under git bash where the mount syntax
# is not understood. I don't think there's any reason this change can't go into
# build-tools upstream.
linux darwin windows: $(GOFILES)
@echo "building $@ from $(SRC_AND_UNDER)"
@$(shell rm -f VERSION.txt)
@$(shell mkdir -p bin/$@ $(GOTMP)/{std/$@,bin,src/$(PKG)})
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v "/$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG)" \
-v "/$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG)" \
-v "/$$PWD/bin/$@:/go/bin$(DOCKERMOUNTFLAG)" \
-v "/$$PWD/bin/$@:/go/bin/$@$(DOCKERMOUNTFLAG)" \
-v "/$$PWD/$(GOTMP)/std/$@:/usr/local/go/pkg/$@_amd64_static$(DOCKERMOUNTFLAG)" \
-e CGO_ENABLED=0 \
-e GOOS=$@ \
-w //go/src/$(PKG) \
$(BUILD_IMAGE) \
go install -installsuffix static -ldflags ' $(LDFLAGS) ' $(SRC_AND_UNDER)
@$(shell touch $@)
@echo $(VERSION) >VERSION.txt
File renamed without changes.
2 changes: 1 addition & 1 deletion build-tools/build_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tar -xf $local_file
rm -rf build-tools/*
cp -r $internal_name/ build-tools/
rm -rf $internal_name/
rm -rf build-tools/{tests,circle.yml,.circleci,.github,.appveyor.yml}
rm -rf build-tools/{tests,circle.yml,.circleci,.github,.appveyor.yml,.buildkite}
touch build-tools/build-tools-VERSION-$tag.txt
git add build-tools
echo "Updated build-tools to $tag
Expand Down
109 changes: 61 additions & 48 deletions build-tools/makefile_components/base_build_go.mak
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
##### comment about what you did and why.


.PHONY: all build test push clean container-clean bin-clean version static govendor gofmt govet golint
.PHONY: all build test push clean container-clean bin-clean version static govendor gofmt govet golint golangci-lint container
GOTMP=.gotmp

SHELL = /bin/bash
Expand All @@ -14,7 +14,7 @@ GOFILES = $(shell find $(SRC_DIRS) -name "*.go")

BUILD_OS = $(shell go env GOHOSTOS)

BUILD_IMAGE ?= drud/golang-build-container:v0.5.5
BUILD_IMAGE ?= drud/golang-build-container:v1.10.3

BUILD_BASE_DIR ?= $$PWD

Expand All @@ -23,6 +23,7 @@ SRC_AND_UNDER = $(patsubst %,./%/...,$(SRC_DIRS))

GOMETALINTER_ARGS ?= --vendored-linters --disable-all --enable=gofmt --enable=vet --enable=vetshadow --enable=golint --enable=errcheck --enable=staticcheck --enable=ineffassign --enable=varcheck --enable=deadcode --deadline=2m

GOLANGCI_LINT_ARGS ?= --out-format=line-number --disable-all --enable=gofmt --enable=govet --enable=golint --enable=errcheck --enable=staticcheck --enable=ineffassign --enable=varcheck --enable=deadcode

COMMIT := $(shell git describe --tags --always --dirty)
BUILDINFO = $(shell echo Built $$(date) $$(whoami)@$$(hostname) $(BUILD_IMAGE) )
Expand All @@ -35,26 +36,28 @@ LDFLAGS := -extldflags -static $(VERSION_LDFLAGS)
DOCKERMOUNTFLAG := :delegated

PWD=$(shell pwd)
S =
ifeq ($(BUILD_OS),windows)
TMPPWD=$(shell cmd /C echo %cd%)
PWD=$(shell echo "$(TMPPWD)" | awk '{gsub("\\\\", "/"); print}' )
# On Windows docker toolbox, volume mounts oddly need a // at the beginning for things to work out, so
# add that extra slash only on Windows.
S=/
endif

build: linux darwin
build: $(BUILD_OS)

linux darwin windows: $(GOFILES)
@echo "building $@ from $(SRC_AND_UNDER)"
@$(shell rm -f VERSION.txt)
@$(shell mkdir -p bin/$@ $(GOTMP)/{std/$@,bin,src/$(PKG)})
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-v $(PWD)/bin/$@:/go/bin$(DOCKERMOUNTFLAG) \
-v $(PWD)/bin/$@:/go/bin/$@$(DOCKERMOUNTFLAG) \
-v $(PWD)/$(GOTMP)/std/$@:/usr/local/go/pkg/$@_amd64_static$(DOCKERMOUNTFLAG) \
docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v "$(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG)" \
-v "$(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG)" \
-v "$(S)$$PWD/bin/$@:/go/bin$(DOCKERMOUNTFLAG)" \
-v "$(S)$$PWD/bin/$@:/go/bin/$@$(DOCKERMOUNTFLAG)" \
-v "$(S)$$PWD/$(GOTMP)/std/$@:/usr/local/go/pkg/$@_amd64_static$(DOCKERMOUNTFLAG)" \
-e CGO_ENABLED=0 \
-e GOOS=$@ \
-w /go/src/$(PKG) \
-w $(S)/go/src/$(PKG) \
$(BUILD_IMAGE) \
go install -installsuffix static -ldflags ' $(LDFLAGS) ' $(SRC_AND_UNDER)
@$(shell touch $@)
Expand All @@ -63,111 +66,121 @@ linux darwin windows: $(GOFILES)
govendor:
@echo -n "Using govendor to check for missing dependencies and unused dependencies: "
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w /go/src/$(PKG) \
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w $(S)/go/src/$(PKG) \
$(BUILD_IMAGE) \
bash -c 'OUT=$$(govendor list +missing +unused); if [ -n "$$OUT" ]; then echo "$$OUT"; exit 1; fi'

gofmt:
@echo "Checking gofmt: "
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w /go/src/$(PKG) \
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w $(S)/go/src/$(PKG) \
$(BUILD_IMAGE) \
bash -c 'export OUT=$$(gofmt -l $(SRC_DIRS)) && if [ -n "$$OUT" ]; then echo "These files need gofmt -w: $$OUT"; exit 1; fi'

govet:
@echo "Checking go vet: "
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w /go/src/$(PKG) \
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w $S/go/src/$(PKG) \
$(BUILD_IMAGE) \
bash -c 'go vet $(SRC_AND_UNDER)'

golint:
@echo "Checking golint: "
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w /go/src/$(PKG) \
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w $(S)/go/src/$(PKG) \
$(BUILD_IMAGE) \
bash -c 'export OUT=$$(golint $(SRC_AND_UNDER)) && if [ -n "$$OUT" ]; then echo "Golint problems discovered: $$OUT"; exit 1; fi'

errcheck:
@echo "Checking errcheck: "
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w /go/src/$(PKG) \
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w $(S)/go/src/$(PKG) \
$(BUILD_IMAGE) \
errcheck $(SRC_AND_UNDER)

staticcheck:
@echo "Checking staticcheck: "
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w /go/src/$(PKG) \
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w $(S)/go/src/$(PKG) \
$(BUILD_IMAGE) \
staticcheck $(SRC_AND_UNDER)

unused:
@echo "Checking unused variables and functions: "
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w /go/src/$(PKG) \
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w $(S)/go/src/$(PKG) \
$(BUILD_IMAGE) \
unused $(SRC_AND_UNDER)

codecoroner:
@echo "Checking codecoroner for unused functions: "
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w /go/src/$(PKG) \
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w $(S)/go/src/$(PKG) \
$(BUILD_IMAGE) \
bash -c 'OUT=$$(codecoroner -tests -ignore vendor funcs $(SRC_AND_UNDER)); if [ -n "$$OUT" ]; then echo "$$OUT"; exit 1; fi' \


varcheck:
@echo "Checking unused globals and struct members: "
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w /go/src/$(PKG) \
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w $(S)/go/src/$(PKG) \
$(BUILD_IMAGE) \
varcheck $(SRC_AND_UNDER) && structcheck $(SRC_AND_UNDER)

misspell:
@echo "Checking for misspellings: "
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w /go/src/$(PKG) \
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w $(S)/go/src/$(PKG) \
$(BUILD_IMAGE) \
misspell $(SRC_DIRS)

gometalinter:
@echo "gometalinter: "
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w /go/src/$(PKG) \
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w $(S)/go/src/$(PKG) \
$(BUILD_IMAGE) \
gometalinter $(GOMETALINTER_ARGS) $(SRC_AND_UNDER)
time gometalinter $(GOMETALINTER_ARGS) $(SRC_AND_UNDER)

golangci-lint:
@echo "golangci-lint: "
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(S)$$PWD:/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-w $(S)/go/src/$(PKG) \
$(BUILD_IMAGE) \
time bash -c "golangci-lint run $(GOLANGCI_LINT_ARGS) $(SRC_AND_UNDER)"

version:
@echo VERSION:$(VERSION)

clean: container-clean bin-clean
go clean -cache || echo "You're not running latest golang locally" # Make sure the local go cache is clean for testing
@go clean -cache || echo "You're not running latest golang locally" # Make sure the local go cache is clean for testing

container-clean:
$(shell rm -rf .container-* .dockerfile* .push-* linux darwin windows container VERSION.txt .docker_image)
@if docker image inspect $(DOCKER_REPO):$(VERSION) >/dev/null 2>&1; then docker rmi -f $(DOCKER_REPO):$(VERSION); fi
@rm -rf .container-* .dockerfile* .push-* linux darwin windows container VERSION.txt .docker_image

bin-clean:
$(shell rm -rf $(GOTMP) bin .tmp)
Expand Down
2 changes: 0 additions & 2 deletions build-tools/makefile_components/base_build_python-docker.mak
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ SHELL := /bin/bash

PWD := $(shell pwd)

BUILD_IMAGE ?= drud/golang-build-container:v0.5.4

all: VERSION.txt build

build: linux
Expand Down
13 changes: 8 additions & 5 deletions build-tools/makefile_components/base_container.mak
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ SANITIZED_DOCKER_REPO = $(subst /,_,$(DOCKER_REPO))

DOTFILE_IMAGE = $(subst /,_,$(IMAGE))-$(VERSION)

container: linux .container-$(DOTFILE_IMAGE) container-name

.container-$(DOTFILE_IMAGE): linux Dockerfile.in
@sed -e 's|UPSTREAM_REPO|$(UPSTREAM_REPO)|g' Dockerfile.in > .dockerfile
container: $(wildcard Dockerfile*)
# UPSTREAM_REPO in the Dockerfile.in will be changed to the value from Makefile; this is deprecated.
# There's no reason not to just use Dockerfile now.
@if [ -f Dockerfile.in ]; then sed -e 's|UPSTREAM_REPO|$(UPSTREAM_REPO)|g' Dockerfile.in > .dockerfile; else cp Dockerfile .dockerfile; fi
# Add information about the commit into .docker_image, to be added to the build.
@echo "$(DOCKER_REPO):$(VERSION) commit=$(shell git describe --tags --always)" >.docker_image
# Add the .docker_image into the build so it's easy to figure out where a docker image came from.
@echo "ADD .docker_image /$(SANITIZED_DOCKER_REPO)_VERSION_INFO.txt" >>.dockerfile
docker build -t $(DOCKER_REPO):$(VERSION) $(DOCKER_ARGS) -f .dockerfile .
@docker images -q $(DOCKER_REPO):$(VERSION) > $@
@docker images -q $(DOCKER_REPO):$(VERSION) >/dev/null


container-name:
@echo "container: $(DOCKER_REPO):$(VERSION)"
1 change: 1 addition & 0 deletions cmd/ddev/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var ConfigCommand *cobra.Command = &cobra.Command{

// Support the show-config-location flag.
if showConfigLocation {
// nolint: vetshadow
activeApp, err := ddevapp.GetActiveApp("")
if err != nil {
if strings.Contains(err.Error(), "Have you run 'ddev config'") {
Expand Down
29 changes: 29 additions & 0 deletions containers/ddev-dbserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM alpine:3.7

ENV MYSQL_DATABASE db
ENV MYSQL_USER db
ENV MYSQL_PASSWORD db
ENV MYSQL_ROOT_PASSWORD root

# Install mariadb and other packages
RUN apk add --no-cache mariadb mariadb-client bash tzdata shadow
# Remove the installed version as we need to set up our own from scratch

RUN rm -rf /var/lib/mysql/* /etc/mysql
RUN mkdir -p /var/lib/mysql && chmod 777 /var/lib/mysql

ADD files /

RUN chmod ugo+x /healthcheck.sh

# Security-sensitive changes: Make sure our start script can do what is needed
# But make sure these are right
RUN chmod ugo+wx /mnt /var/tmp
RUN chmod -R ugo+wx /var/log /var/tmp/mysqlbase

ENTRYPOINT ["/docker-entrypoint.sh"]

EXPOSE 3306
# The following line overrides any cmd entry
CMD []
HEALTHCHECK --interval=2s --retries=30 CMD ["/healthcheck.sh"]
File renamed without changes.

0 comments on commit 8d88658

Please sign in to comment.