-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from danielvrog/main
Add Makefile and Dockefile
- Loading branch information
Showing
8 changed files
with
76 additions
and
6 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
main | ||
main.tmpl | ||
config | ||
bin/* |
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,13 @@ | ||
ARG GO_VERSION=1.16 | ||
FROM golang:${GO_VERSION} AS builder | ||
COPY . /terra-crust | ||
WORKDIR /terra-crust | ||
RUN make compile | ||
|
||
|
||
FROM golang:${GO_VERSION} | ||
ARG ARCH=amd64 | ||
WORKDIR /opt/ | ||
COPY --from=builder /terra-crust/bin/terra-crust-linux-${ARCH} ./ | ||
RUN mv terra-crust-linux-${ARCH} terra-crust | ||
CMD ["./terra-crust"] |
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,55 @@ | ||
SHELL := /bin/bash | ||
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
export GO_VERSION ?= $(shell grep -E "^go " go.mod | awk -F' ' '{print $$2}' ) | ||
export GOLANGCI_LINT_VERSION=v1.41.1 | ||
export MAIN_GO=internal/cmd/main.go | ||
|
||
.PHONY: help | ||
help: ## Show this help message. | ||
|
||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
|
||
get-go-dependancies: ## Get dependancies as devlared in the project | ||
$(info) | ||
$(info ========[ $@ ]========) | ||
go get -v -t -d ./... | ||
|
||
get-linter: ## Get golangci-lint | ||
$(info) | ||
$(info ========[ $@ ]========) | ||
@if ! golangci-lint --version 2>/dev/null; then \ | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION};\ | ||
fi;\ | ||
|
||
lint: get-linter ## Run linter | ||
$(info) | ||
$(info ========[ $@ ]========) | ||
golangci-lint run --fast --enable-all -D scopelint -D gocyclo -D godot -D funlen -D lll -D gocognit -D gofumpt -D wsl -D gomnd --skip-dirs-use-default | ||
|
||
test: ## Run go tests | ||
$(info) | ||
$(info ========[ $@ ]========) | ||
go test ./... | ||
|
||
build: get-go-dependancies lint ## Build | ||
$(info) | ||
$(info ========[ $@ ]========) | ||
go build -v ${MAIN_GO} | ||
|
||
|
||
compile: build ## Compile binaries for multiple OSs and architectures | ||
$(info) | ||
$(info ========[ $@ ]========) | ||
@for os in "linux" "darwin"; do \ | ||
for arch in "amd64" "arm64"; do \ | ||
echo "$${os} - $${arch}"; \ | ||
GOOS=$${os} GOARCH=$${arch} go build -o bin/terra-crust-$${os}-$${arch} ${MAIN_GO}; \ | ||
done \ | ||
done | ||
|
||
build-docker: ## Build a docker image | ||
$(info) | ||
$(info ========[ $@ ]========) | ||
docker build -t appsflyer/terra-crust:$$(git rev-parse --short HEAD) . |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.