From dabd9e220891aac2986dd67e1936b3cc9dc40e42 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Thu, 14 Mar 2019 16:22:04 +0100 Subject: [PATCH] New packaging system. --- .goreleaser.yml | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 7 +++--- Makefile | 48 +++++++++++++++++++++++------------------- build.Dockerfile | 4 ++++ 4 files changed, 88 insertions(+), 26 deletions(-) create mode 100644 .goreleaser.yml diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 000000000..63b62f02a --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,55 @@ +project_name: traefik + +before: + hooks: + - go generate + +builds: + - binary: traefik + + main: ./cmd/traefik/traefik.go + env: + - CGO_ENABLED=0 + ldflags: + - -s -w -X github.com/containous/traefik/version.Version={{.Version}} -X github.com/containous/traefik/version.Codename={{.Env.CODENAME}} -X github.com/containous/traefik/version.BuildDate={{.Date}} + + goos: + - linux + - darwin + - windows + - freebsd + - openbsd + goarch: + - amd64 + - 386 + - arm + - arm64 + - ppc64le + goarm: + - 7 + - 6 + - 5 + ignore: + - goos: darwin + goarch: 386 + - goos: openbsd + goarch: arm + - goos: freebsd + goarch: arm + +changelog: + skip: true + +archive: + name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm + }}v{{ .Arm }}{{ end }}' + format: tar.gz + format_overrides: + - goos: windows + format: zip + files: + - LICENSE.md + - CHANGELOG.md + +release: + disable: true diff --git a/.travis.yml b/.travis.yml index 89c32a580..1125c597f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ env: - REPO: $TRAVIS_REPO_SLUG - VERSION: $TRAVIS_TAG - CODENAME: maroilles - - N_MAKE_JOBS: 2 script: - echo "Skipping tests... (Tests are executed on SemaphoreCI)" @@ -27,12 +26,12 @@ before_deploy: docker version; make image; if [ "$TRAVIS_TAG" ]; then - make -j${N_MAKE_JOBS} crossbinary-parallel; - tar cfz dist/traefik-${VERSION}.src.tar.gz --exclude-vcs --exclude dist .; + make release-packages; fi; - curl -sfL https://raw.githubusercontent.com/containous/structor/master/godownloader.sh | bash -s -- -b "${GOPATH}/bin" v1.4.0 + curl -sfL https://raw.githubusercontent.com/containous/structor/master/godownloader.sh | bash -s -- -b "${GOPATH}/bin" v1.6.0 structor -o containous -r traefik --dockerfile-url="https://raw.githubusercontent.com/containous/traefik/v1.7/docs.Dockerfile" --menu.js-url="https://raw.githubusercontent.com/containous/structor/master/traefik-menu.js.gotmpl" --rqts-url="https://raw.githubusercontent.com/containous/structor/master/requirements-override.txt" --exp-branch=master --debug; fi + deploy: - provider: releases api_key: ${GITHUB_TOKEN} diff --git a/Makefile b/Makefile index 763f53fde..90e54c3a7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all docs docs-serve +.PHONY: all docs docs-serve clear-static TRAEFIK_ENVS := \ -e OS_ARCH_ARG \ @@ -13,6 +13,11 @@ TRAEFIK_ENVS := \ SRCS = $(shell git ls-files '*.go' | grep -v '^vendor/') +TAG_NAME := $(shell git tag -l --contains HEAD) +SHA := $(shell git rev-parse HEAD) +VERSION_GIT := $(if $(TAG_NAME),$(TAG_NAME),$(SHA)) +VERSION := $(if $(VERSION),$(VERSION),$(VERSION_GIT)) + BIND_DIR := "dist" TRAEFIK_MOUNT := -v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/containous/traefik/$(BIND_DIR)" @@ -37,13 +42,6 @@ all: generate-webui build ## validate all checks, build linux binary, run all te binary: generate-webui build ## build the linux binary $(DOCKER_RUN_TRAEFIK) ./script/make.sh generate binary -crossbinary: generate-webui build ## cross build the non-linux binaries - $(DOCKER_RUN_TRAEFIK) ./script/make.sh generate crossbinary - -crossbinary-parallel: - $(MAKE) generate-webui - $(MAKE) build crossbinary-default crossbinary-others - crossbinary-default: generate-webui build $(DOCKER_RUN_TRAEFIK_NOTTY) ./script/make.sh generate crossbinary-default @@ -51,13 +49,6 @@ crossbinary-default-parallel: $(MAKE) generate-webui $(MAKE) build crossbinary-default -crossbinary-others: generate-webui build - $(DOCKER_RUN_TRAEFIK_NOTTY) ./script/make.sh generate crossbinary-others - -crossbinary-others-parallel: - $(MAKE) generate-webui - $(MAKE) build crossbinary-others - test: build ## run the unit and integration tests $(DOCKER_RUN_TRAEFIK) ./script/make.sh generate test-unit binary test-integration @@ -74,9 +65,6 @@ validate: build ## validate code, vendor and autogen build: dist docker build $(DOCKER_BUILD_ARGS) -t "$(TRAEFIK_DEV_IMAGE)" -f build.Dockerfile . -build-webui: - docker build -t traefik-webui -f webui/Dockerfile webui - build-no-cache: dist docker build --no-cache -t "$(TRAEFIK_DEV_IMAGE)" -f build.Dockerfile . @@ -95,9 +83,6 @@ docs: docs-serve: make -C ./docs docs-serve -clear-static: - rm -rf static - dist: mkdir dist @@ -106,10 +91,17 @@ run-dev: go build ./cmd/traefik ./traefik +clear-static: + rm -rf static + +build-webui: + docker build -t traefik-webui -f webui/Dockerfile webui + generate-webui: build-webui if [ ! -d "static" ]; then \ mkdir -p static; \ docker run --rm -v "$$PWD/static":'/src/static' traefik-webui npm run build; \ + docker run --rm -v "$$PWD/static":'/src/static' traefik-webui chown -R $(shell id -u):$(shell id -g) ../static; \ echo 'For more informations show `webui/readme.md`' > $$PWD/static/DONT-EDIT-FILES-IN-THIS-DIRECTORY.md; \ fi @@ -123,7 +115,7 @@ fmt: gofmt -s -l -w $(SRCS) pull-images: - grep --no-filename -E '^\s+image:' ./integration/resources/compose/*.yml | awk '{print $$2}' | sort | uniq | xargs -P 6 -n 1 docker pull + grep --no-filename -E '^\s+image:' ./integration/resources/compose/*.yml | awk '{print $$2}' | sort | uniq | xargs -P 6 -n 1 docker pull dep-ensure: dep ensure -v @@ -134,3 +126,15 @@ dep-prune: help: ## this help @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +release-packages: generate-webui build + rm -rf dist + $(DOCKER_RUN_TRAEFIK_NOTTY) goreleaser release --skip-publish + $(DOCKER_RUN_TRAEFIK_NOTTY) tar cfz dist/traefik-${VERSION}.src.tar.gz \ + --exclude-vcs \ + --exclude .idea \ + --exclude .travis \ + --exclude .semaphoreci \ + --exclude .github \ + --exclude dist . + $(DOCKER_RUN_TRAEFIK_NOTTY) chown -R $(shell id -u):$(shell id -g) dist/ diff --git a/build.Dockerfile b/build.Dockerfile index d8cd3d292..e8b2a2c95 100644 --- a/build.Dockerfile +++ b/build.Dockerfile @@ -4,9 +4,13 @@ RUN apk --update upgrade \ && apk --no-cache --no-progress add git mercurial bash gcc musl-dev curl tar \ && rm -rf /var/cache/apk/* +# Download golangci-lint and misspell binary to bin folder in $GOPATH RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.15.0 \ && go get github.com/client9/misspell/cmd/misspell +# Download goreleaser binary to bin folder in $GOPATH +RUN curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh + # Which docker version to test on ARG DOCKER_VERSION=17.03.2 ARG DEP_VERSION=0.5.0