-
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.
refac: Use an overlay directory to create Makefiles and Dockerfiles
Allows for easier individual customization required for accepatnce tests. Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
- Loading branch information
Showing
31 changed files
with
907 additions
and
41 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
File renamed without changes.
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,11 @@ | ||
LDFLAGS ?= "-s -w" | ||
BUILDFLAGS ?= -trimpath -ldflags $(LDFLAGS) | ||
TESTFLAGS ?= | ||
|
||
.PHONY: generate | ||
generate: | ||
go generate ./... | ||
|
||
.PHONY: test | ||
test: | ||
go test $(BUILDFLAGS) $(TESTFLAGS) ./... |
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,7 @@ | ||
FROM scratch | ||
ARG USER=65534 | ||
ARG BIN_FILE=./dist/${TARGETOS}/${TARGETARCH}/auditlogs | ||
USER $USER | ||
COPY --chown=$USER backend/services/auditlogs/config.yaml /etc/auditlogs/config.yaml | ||
COPY --chown=$USER ${BIN_FILE} /usr/bin/auditlogs | ||
ENTRYPOINT ["/usr/bin/auditlogs", "--config", "/etc/auditlogs/config.yaml"] |
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
overlay/backend/services/create-artifact-worker/Dockerfile
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,12 @@ | ||
FROM scratch | ||
ARG TARGETARCH | ||
ARG TARGETOS | ||
ARG USER=65534 | ||
ARG BIN_FILE=./dist/${TARGETOS}/${TARGETARCH}/create-artifact-worker | ||
ARG BIN_WORKFLOWS=./dist/${TARGETOS}/${TARGETARCH}/workflows | ||
USER $USER | ||
COPY --chown=$USER backend/services/create-artifact-worker/config.yaml /etc/create-artifact-worker/config.yaml | ||
COPY --chown=$USER ${BIN_WORKFLOWS} /usr/bin/workflows | ||
COPY --chown=$USER ${BIN_FILE} /usr/bin/create-artifact-worker | ||
ENTRYPOINT ["/usr/bin/workflows", "--config", "/etc/create-artifact-worker/config.yaml"] | ||
CMD ["worker"] |
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,62 @@ | ||
COMPONENT := $(notdir $(shell go list)) | ||
GIT_ROOT := $(shell git rev-parse --show-toplevel) | ||
VERSION := $(shell git describe --tag --dirty 2>/dev/null) | ||
|
||
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 = $(bindir)/$(COMPONENT).test | ||
build-test: build | ||
|
||
.PHONY: generate | ||
generate: | ||
go generate ./... | ||
|
||
.PHONY: test | ||
test: | ||
go test $(BUILDFLAGS) $(TESTFLAGS) ./... | ||
|
||
.PHONY: docker | ||
docker: build | ||
$(MAKE) -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 DOCKER_BIN = $(subst $(GIT_ROOT),,$(binfile)).test | ||
docker-acceptance: build-test | ||
$(MAKE) -C ../workflows build-test | ||
docker build $(DOCKER_ARGS) \ | ||
--build-arg BIN_FILE=$(DOCKER_BIN) \ | ||
--platform $(GOOS)/$(GOARCH) \ | ||
-f Dockerfile \ | ||
-t $(DOCKER_TAG) \ | ||
$(GIT_ROOT) |
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,7 @@ | ||
FROM scratch | ||
ARG USER=65534 | ||
ARG BIN_FILE=./dist/${TARGETOS}/${TARGETARCH}/deployments | ||
USER $USER | ||
COPY --chown=$USER backend/services/deployments/config.yaml /etc/deployments/config.yaml | ||
COPY --chown=$USER ${BIN_FILE} /usr/bin/deployments | ||
ENTRYPOINT ["/usr/bin/deployments", "--config", "/etc/deployments/config.yaml"] |
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,60 @@ | ||
COMPONENT := $(notdir $(shell go list)) | ||
GIT_ROOT := $(shell git rev-parse --show-toplevel) | ||
VERSION := $(shell git describe --tag --dirty 2>/dev/null) | ||
|
||
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 ?= | ||
|
||
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 = $(bindir)/$(COMPONENT).test | ||
build-test: build | ||
|
||
.PHONY: generate | ||
generate: | ||
go generate ./... | ||
|
||
.PHONY: test | ||
test: | ||
go test $(BUILDFLAGS) $(TESTFLAGS) ./... | ||
|
||
.PHONY: docker | ||
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 DOCKER_BIN = $(subst $(GIT_ROOT),,$(binfile)).test | ||
docker-acceptance: build-test | ||
docker build $(DOCKER_ARGS) \ | ||
--build-arg BIN_FILE=$(DOCKER_BIN) \ | ||
--platform $(GOOS)/$(GOARCH) \ | ||
-f Dockerfile \ | ||
-t $(DOCKER_TAG) \ | ||
$(GIT_ROOT) |
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,7 @@ | ||
FROM scratch | ||
ARG USER=65534 | ||
ARG BIN_FILE=./dist/${TARGETOS}/${TARGETARCH}/deviceauth | ||
USER $USER | ||
COPY --chown=$USER backend/services/deviceauth/config.yaml /etc/deviceauth/config.yaml | ||
COPY --chown=$USER ${BIN_FILE} /usr/bin/deviceauth | ||
ENTRYPOINT ["/usr/bin/deviceauth", "--config", "/etc/deviceauth/config.yaml"] |
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,60 @@ | ||
COMPONENT := $(notdir $(shell go list)) | ||
GIT_ROOT := $(shell git rev-parse --show-toplevel) | ||
VERSION := $(shell git describe --tag --dirty 2>/dev/null) | ||
|
||
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 = $(bindir)/$(COMPONENT).test | ||
build-test: build | ||
|
||
.PHONY: generate | ||
generate: | ||
go generate ./... | ||
|
||
.PHONY: test | ||
test: | ||
go test $(BUILDFLAGS) $(TESTFLAGS) ./... | ||
|
||
.PHONY: docker | ||
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 DOCKER_BIN = $(subst $(GIT_ROOT),,$(binfile)).test | ||
docker-acceptance: build-test | ||
docker build $(DOCKER_ARGS) \ | ||
--build-arg BIN_FILE=$(DOCKER_BIN) \ | ||
--platform $(GOOS)/$(GOARCH) \ | ||
-f Dockerfile \ | ||
-t $(DOCKER_TAG) \ | ||
$(GIT_ROOT) |
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,7 @@ | ||
FROM scratch | ||
ARG USER=65534 | ||
ARG BIN_FILE=./dist/${TARGETOS}/${TARGETARCH}/deviceconfig | ||
USER $USER | ||
COPY --chown=$USER backend/services/deviceconfig/config.yaml /etc/deviceconfig/config.yaml | ||
COPY --chown=$USER ${BIN_FILE} /usr/bin/deviceconfig | ||
ENTRYPOINT ["/usr/bin/deviceconfig", "--config", "/etc/deviceconfig/config.yaml"] |
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,60 @@ | ||
COMPONENT := $(notdir $(shell go list)) | ||
GIT_ROOT := $(shell git rev-parse --show-toplevel) | ||
VERSION := $(shell git describe --tag --dirty 2>/dev/null) | ||
|
||
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 = $(bindir)/$(COMPONENT).test | ||
build-test: build | ||
|
||
.PHONY: generate | ||
generate: | ||
go generate ./... | ||
|
||
.PHONY: test | ||
test: | ||
go test $(BUILDFLAGS) $(TESTFLAGS) ./... | ||
|
||
.PHONY: docker | ||
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 DOCKER_BIN = $(subst $(GIT_ROOT),,$(binfile)).test | ||
docker-acceptance: build-test | ||
docker build $(DOCKER_ARGS) \ | ||
--build-arg BIN_FILE=$(DOCKER_BIN) \ | ||
--platform $(GOOS)/$(GOARCH) \ | ||
-f Dockerfile \ | ||
-t $(DOCKER_TAG) \ | ||
$(GIT_ROOT) |
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,7 @@ | ||
FROM scratch | ||
ARG USER=65534 | ||
ARG BIN_FILE=./dist/${TARGETOS}/${TARGETARCH}/deviceconnect | ||
USER $USER | ||
COPY --chown=$USER backend/services/deviceconnect/config.yaml /etc/deviceconnect/config.yaml | ||
COPY --chown=$USER ${BIN_FILE} /usr/bin/deviceconnect | ||
ENTRYPOINT ["/usr/bin/deviceconnect", "--config", "/etc/deviceconnect/config.yaml"] |
Oops, something went wrong.