-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(make): Update
docker
targets to use updated Dockerfiles
Refactored common parts to parent directory. Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
- Loading branch information
Showing
12 changed files
with
126 additions
and
807 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Makefile.common initializes varialbes and common targets (build* test*) | ||
# for all backend services. | ||
MENDER_IMAGE_PREFIX ?= localhost:5000/mender-server | ||
MENDER_IMAGE_TAG ?= $(MENDER_IMAGE_TAG_DEFAULT) | ||
|
||
MENDER_IMAGE_TAG_DEFAULT := latest | ||
|
||
bindir ?= $(GIT_ROOT)/dist | ||
binfile ?= $(bindir)/$(COMPONENT)_$(GOOS)-$(GOARCH) | ||
|
||
VERSION := $(shell git describe --tag --dirty 2>/dev/null) | ||
GIT_ROOT := $(shell git rev-parse --show-toplevel) | ||
MAKEDIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
DOCFILES := $(wildcard docs/*_api.yml) | ||
|
||
GOFILES := $(shell find -name '*.go' -not -name '_test.go') | ||
GOTESTFILES := $(shell find -name '_test.go') | ||
CGO_ENABLED ?= 0 | ||
GOARCH := $(shell go env GOARCH) | ||
GOOS := $(shell go env GOOS) | ||
GOMODDIR := $(shell go list -m -f '{{.Dir}}') | ||
|
||
LDFLAGS ?= -s -w | ||
BUILDFLAGS ?= -trimpath | ||
TESTFLAGS ?= | ||
PYTEST_ARGS ?= | ||
|
||
# Convert TAGS to a `-tags` BUILDFLAG by joining the list by comma. | ||
_none := | ||
_space := $(_none) $(_none) | ||
_comma := , | ||
BUILDFLAGS += $(let tags,$(TAGS),-tags=$(subst $(_space),$(_comma),$(tags))) | ||
|
||
# DOCKER_PLATFORM default is defined with respect to the docker server. | ||
# This fixes the default case on darwin where docker is running inside a VM (linux). | ||
DOCKER_PLATFORM ?= $(shell docker system info -f ' \ | ||
{{- .OSType}}/{{- if eq .Architecture "aarch64" -}} \ | ||
arm64 \ | ||
{{- else -}} \ | ||
amd64 \ | ||
{{- end -}} \ | ||
') | ||
DOCKER_TAG = $(MENDER_IMAGE_PREFIX)/$(COMPONENT):$(MENDER_IMAGE_TAG) | ||
|
||
$(binfile): $(GOFILES) | ||
# TODO: Add -ldflags "-X ...$(Version)" | ||
env CGO_ENABLED=$(CGO_ENABLED) \ | ||
GOOS=$(GOOS) \ | ||
GOARCH=$(GOARCH) \ | ||
go build -o $(binfile) \ | ||
-ldflags $(LDFLAGS) \ | ||
$(BUILDFLAGS) | ||
|
||
.PHONY: build | ||
build: $(binfile) | ||
|
||
.PHONY: generate | ||
generate: | ||
go generate ./... | ||
|
||
.PHONY: test-unit | ||
test-unit: | ||
go test $(BUILDFLAGS) $(TESTFLAGS) ./... | ||
|
||
.PHONY: test | ||
test: test-unit test-acceptance | ||
|
||
docker-acceptance: export TAGS += acceptance | ||
docker-acceptance: export BUILDFLAGS += -cover -installsuffix=.test | ||
%-acceptance test-acceptance-run: export MENDER_IMAGE_TAG_DEFAULT := test | ||
|
||
.PHONY: docker | ||
docker: | ||
docker build $(DOCKER_ARGS) \ | ||
--platform $(DOCKER_PLATFORM) \ | ||
-f Dockerfile \ | ||
--build-arg GOFLAGS="$(BUILDFLAGS)" \ | ||
--build-arg GOLDFLAGS="$(LDFLAGS)" \ | ||
-t $(DOCKER_TAG) \ | ||
$(GIT_ROOT)/backend | ||
|
||
.PHONY: docker-acceptance | ||
docker-acceptance: docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,3 @@ | ||
COMPONENT := $(notdir $(shell go list)) | ||
GIT_ROOT := $(shell git rev-parse --show-toplevel) | ||
VERSION := $(shell git describe --tag --dirty 2>/dev/null) | ||
COMPONENT := create-artifact-worker | ||
|
||
distdir ?= $(GIT_ROOT)/dist | ||
bindir ?= $(distdir)/$(GOOS)/$(GOARCH) | ||
binfile ?= $(bindir)/$(COMPONENT) | ||
|
||
CGO_ENABLED ?= 0 | ||
GOARCH := $(shell go env GOARCH) | ||
GOOS := $(shell go env GOOS) | ||
GOMODDIR := $(shell go list -m -f '{{.Dir}}') | ||
|
||
LDFLAGS ?= "-s -w" | ||
BUILDFLAGS ?= -trimpath -ldflags $(LDFLAGS) | ||
TESTFLAGS ?= | ||
|
||
DOCKER_TAG ?= $(COMPONENT):latest | ||
DOCKER_BIN ?= $(subst $(GIT_ROOT),,$(binfile)) # Repo-local file to binary | ||
|
||
.PHONY: build | ||
build: | ||
# TODO: Add -ldflags "-X ...Version" | ||
env CGO_ENABLED=$(CGO_ENABLED) \ | ||
GOOS=$(GOOS) \ | ||
GOARCH=$(GOARCH) \ | ||
go build -o $(binfile) $(BUILDFLAGS) | ||
|
||
.PHONY: build-test | ||
build-test: BUILDFLAGS += -cover -installsuffix .test | ||
build-test: binfile = $(GIT_ROOT)/backend/tests/bin/$(COMPONENT).test | ||
build-test: build | ||
|
||
.PHONY: generate | ||
generate: | ||
go generate ./... | ||
|
||
.PHONY: test | ||
test: test-unit | ||
|
||
.PHONY: test-unit | ||
test-unit: | ||
go test $(BUILDFLAGS) $(TESTFLAGS) ./... | ||
|
||
.PHONY: test-acceptance | ||
test-acceptance: | ||
|
||
.PHONY: docker | ||
docker: export GOOS = linux | ||
docker: build | ||
$(MAKE) GOOS=$(GOOS) -C ../workflows build | ||
docker build $(DOCKER_ARGS) \ | ||
--build-arg BIN_FILE=$(DOCKER_BIN) \ | ||
--platform $(GOOS)/$(GOARCH) \ | ||
-f Dockerfile \ | ||
-t $(DOCKER_TAG) \ | ||
$(GIT_ROOT) | ||
|
||
.PHONY: docker-acceptance | ||
docker-acceptance: export DOCKER_TAG = $(COMPONENT):test | ||
docker-acceptance: export binfile = $(GIT_ROOT)/backend/tests/bin/$(COMPONENT).test | ||
docker-acceptance: export DOCKER_BIN = $(subst $(GIT_ROOT),,$(binfile)) | ||
docker-acceptance: export GOOS = linux | ||
docker-acceptance: build-test | ||
$(MAKE) GOOS=$(GOOS) -C ../workflows build-test | ||
docker build $(DOCKER_ARGS) \ | ||
--build-arg BIN_FILE=$(DOCKER_BIN) \ | ||
--platform $(GOOS)/$(GOARCH) \ | ||
-f Dockerfile \ | ||
-t $(DOCKER_TAG) \ | ||
$(GIT_ROOT) | ||
include ../Makefile.common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,4 @@ | ||
COMPONENT := $(notdir $(shell go list)) | ||
GIT_ROOT := $(shell git rev-parse --show-toplevel) | ||
VERSION := $(shell git describe --tag --dirty 2>/dev/null) | ||
COMPONENT := deployments | ||
BUILDFLAGS ?= -tags=nopkcs11 -trimpath | ||
|
||
distdir ?= $(GIT_ROOT)/dist | ||
bindir ?= $(distdir)/$(GOOS)/$(GOARCH) | ||
binfile ?= $(bindir)/$(COMPONENT) | ||
|
||
CGO_ENABLED ?= 0 | ||
GOARCH := $(shell go env GOARCH) | ||
GOOS := $(shell go env GOOS) | ||
GOMODDIR := $(shell go list -m -f '{{.Dir}}') | ||
|
||
LDFLAGS ?= "-s -w" | ||
BUILDFLAGS ?= -tags nopkcs11 -trimpath -ldflags $(LDFLAGS) | ||
TESTFLAGS ?= | ||
PYTEST_ARGS ?= | ||
|
||
DOCKER_TAG ?= $(COMPONENT):latest | ||
DOCKER_BIN ?= $(subst $(GIT_ROOT),,$(binfile)) # Repo-local file to binary | ||
|
||
.PHONY: build | ||
build: | ||
# TODO: Add -ldflags "-X ...Version" | ||
env CGO_ENABLED=$(CGO_ENABLED) \ | ||
GOOS=$(GOOS) \ | ||
GOARCH=$(GOARCH) \ | ||
go build -o $(binfile) $(BUILDFLAGS) | ||
|
||
.PHONY: build-test | ||
build-test: BUILDFLAGS += -cover -installsuffix .test | ||
build-test: binfile = $(GIT_ROOT)/backend/tests/bin/$(COMPONENT).test | ||
build-test: build | ||
|
||
.PHONY: generate | ||
generate: | ||
go generate ./... | ||
|
||
.PHONY: test-unit | ||
test-unit: | ||
go test $(BUILDFLAGS) $(TESTFLAGS) ./... | ||
|
||
.PHONY: test-acceptance-run | ||
test-acceptance-run: docker-acceptance | ||
docker compose -f tests/docker-compose.yml run --rm --use-aliases acceptance-tester $(PYTEST_ARGS) | ||
|
||
.PHONY: test-acceptance | ||
test-acceptance: test-acceptance-run | ||
docker compose -f tests/docker-compose.yml down --remove-orphans -v | ||
|
||
.PHONY: test | ||
test: test-unit test-acceptance | ||
|
||
.PHONY: docker | ||
docker: export GOOS = linux | ||
docker: build | ||
docker build $(DOCKER_ARGS) \ | ||
--build-arg BIN_FILE=$(DOCKER_BIN) \ | ||
--platform $(GOOS)/$(GOARCH) \ | ||
-f Dockerfile \ | ||
-t $(DOCKER_TAG) \ | ||
$(GIT_ROOT) | ||
|
||
.PHONY: docker-acceptance | ||
docker-acceptance: export DOCKER_TAG = $(COMPONENT):test | ||
docker-acceptance: export binfile = $(GIT_ROOT)/backend/tests/bin/$(COMPONENT).test | ||
docker-acceptance: export DOCKER_BIN = $(subst $(GIT_ROOT),,$(binfile)) | ||
docker-acceptance: export GOOS = linux | ||
docker-acceptance: build-test | ||
docker build $(DOCKER_ARGS) \ | ||
--build-arg BIN_FILE=$(DOCKER_BIN) \ | ||
--platform $(GOOS)/$(GOARCH) \ | ||
-f Dockerfile \ | ||
-t $(DOCKER_TAG) \ | ||
$(GIT_ROOT) | ||
include ../Makefile.common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,3 @@ | ||
COMPONENT := $(notdir $(shell go list)) | ||
GIT_ROOT := $(shell git rev-parse --show-toplevel) | ||
VERSION := $(shell git describe --tag --dirty 2>/dev/null) | ||
COMPONENT := deviceauth | ||
|
||
distdir ?= $(GIT_ROOT)/dist | ||
bindir ?= $(distdir)/$(GOOS)/$(GOARCH) | ||
binfile ?= $(bindir)/$(COMPONENT) | ||
|
||
CGO_ENABLED ?= 0 | ||
GOARCH := $(shell go env GOARCH) | ||
GOOS := $(shell go env GOOS) | ||
GOMODDIR := $(shell go list -m -f '{{.Dir}}') | ||
|
||
LDFLAGS ?= "-s -w" | ||
BUILDFLAGS ?= -trimpath -ldflags $(LDFLAGS) | ||
TESTFLAGS ?= | ||
PYTEST_ARGS ?= | ||
|
||
DOCKER_TAG ?= $(COMPONENT):latest | ||
DOCKER_BIN ?= $(subst $(GIT_ROOT),,$(binfile)) # Repo-local file to binary | ||
|
||
.PHONY: build | ||
build: | ||
# TODO: Add -ldflags "-X ...Version" | ||
env CGO_ENABLED=$(CGO_ENABLED) \ | ||
GOOS=$(GOOS) \ | ||
GOARCH=$(GOARCH) \ | ||
go build -o $(binfile) $(BUILDFLAGS) | ||
|
||
.PHONY: build-test | ||
build-test: BUILDFLAGS += -cover -installsuffix .test | ||
build-test: binfile = $(GIT_ROOT)/backend/tests/bin/$(COMPONENT).test | ||
build-test: build | ||
|
||
.PHONY: generate | ||
generate: | ||
go generate ./... | ||
|
||
.PHONY: test-unit | ||
test-unit: | ||
go test $(BUILDFLAGS) $(TESTFLAGS) ./... | ||
|
||
.PHONY: test-acceptance-run | ||
test-acceptance-run: docker-acceptance | ||
docker compose -f tests/docker-compose.yml run --rm --use-aliases acceptance-tester $(PYTEST_ARGS) | ||
|
||
.PHONY: test-acceptance | ||
test-acceptance: test-acceptance-run | ||
docker compose -f tests/docker-compose.yml down --remove-orphans -v | ||
|
||
.PHONY: test | ||
test: test-unit test-acceptance | ||
|
||
.PHONY: docker | ||
docker: export GOOS = linux | ||
docker: build | ||
docker build $(DOCKER_ARGS) \ | ||
--build-arg BIN_FILE=$(DOCKER_BIN) \ | ||
--platform $(GOOS)/$(GOARCH) \ | ||
-f Dockerfile \ | ||
-t $(DOCKER_TAG) \ | ||
$(GIT_ROOT) | ||
|
||
.PHONY: docker-acceptance | ||
docker-acceptance: export DOCKER_TAG = $(COMPONENT):test | ||
docker-acceptance: export binfile = $(GIT_ROOT)/backend/tests/bin/$(COMPONENT).test | ||
docker-acceptance: export DOCKER_BIN = $(subst $(GIT_ROOT),,$(binfile)) | ||
docker-acceptance: export GOOS = linux | ||
docker-acceptance: build-test | ||
docker build $(DOCKER_ARGS) \ | ||
--build-arg BIN_FILE=$(DOCKER_BIN) \ | ||
--platform $(GOOS)/$(GOARCH) \ | ||
-f Dockerfile \ | ||
-t $(DOCKER_TAG) \ | ||
$(GIT_ROOT) | ||
include ../Makefile.common |
Oops, something went wrong.