-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Dockerfile * Add Makefile and manage tools using bingo
- Loading branch information
Showing
12 changed files
with
175 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
# Ignore everything | ||
* | ||
|
||
# But not these files: | ||
!.gitignore | ||
!*.mod | ||
!README.md | ||
!Variables.mk | ||
!variables.env | ||
|
||
*tmp.mod |
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,14 @@ | ||
# Project Development Dependencies. | ||
|
||
This is directory which stores Go modules with pinned buildable package that is used within this repository, managed by https://github.com/bwplotka/bingo. | ||
|
||
* Run `bingo get` to install all tools having each own module file in this directory. | ||
* Run `bingo get <tool>` to install <tool> that have own module file in this directory. | ||
* For Makefile: Make sure to put `include .bingo/Variables.mk` in your Makefile, then use $(<upper case tool name>) variable where <tool> is the .bingo/<tool>.mod. | ||
* For shell: Run `source .bingo/variables.env` to source all environment variable for each tool. | ||
* For go: Import `.bingo/variables.go` to for variable names. | ||
* See https://github.com/bwplotka/bingo or -h on how to add, remove or change binaries dependencies. | ||
|
||
## Requirements | ||
|
||
* Go 1.14+ |
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,31 @@ | ||
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.3.1. DO NOT EDIT. | ||
# All tools are designed to be build inside $GOBIN. | ||
BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST))) | ||
GOPATH ?= $(shell go env GOPATH) | ||
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin | ||
GO ?= $(shell which go) | ||
|
||
# Bellow generated variables ensure that every time a tool under each variable is invoked, the correct version | ||
# will be used; reinstalling only if needed. | ||
# For example for goimports variable: | ||
# | ||
# In your main Makefile (for non array binaries): | ||
# | ||
#include .bingo/Variables.mk # Assuming -dir was set to .bingo . | ||
# | ||
#command: $(GOIMPORTS) | ||
# @echo "Running goimports" | ||
# @$(GOIMPORTS) <flags/args..> | ||
# | ||
GOIMPORTS := $(GOBIN)/goimports-v0.1.0 | ||
$(GOIMPORTS): $(BINGO_DIR)/goimports.mod | ||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. | ||
@echo "(re)installing $(GOBIN)/goimports-v0.1.0" | ||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=goimports.mod -o=$(GOBIN)/goimports-v0.1.0 "golang.org/x/tools/cmd/goimports" | ||
|
||
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.36.0 | ||
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod | ||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. | ||
@echo "(re)installing $(GOBIN)/golangci-lint-v1.36.0" | ||
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.36.0 "github.com/golangci/golangci-lint/cmd/golangci-lint" | ||
|
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 @@ | ||
module _ // Fake go.mod auto-created by 'bingo' for go -moddir compatibility with non-Go projects. Commit this file, together with other .mod files. |
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,5 @@ | ||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT | ||
|
||
go 1.15 | ||
|
||
require golang.org/x/tools v0.1.0 // cmd/goimports |
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,5 @@ | ||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT | ||
|
||
go 1.15 | ||
|
||
require github.com/golangci/golangci-lint v1.36.0 // cmd/golangci-lint |
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,14 @@ | ||
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.3.1. DO NOT EDIT. | ||
# All tools are designed to be build inside $GOBIN. | ||
# Those variables will work only until 'bingo get' was invoked, or if tools were installed via Makefile's Variables.mk. | ||
GOBIN=${GOBIN:=$(go env GOBIN)} | ||
|
||
if [ -z "$GOBIN" ]; then | ||
GOBIN="$(go env GOPATH)/bin" | ||
fi | ||
|
||
|
||
GOIMPORTS="${GOBIN}/goimports-v0.1.0" | ||
|
||
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.36.0" | ||
|
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,22 @@ | ||
FROM golang:1.15-alpine3.13 as builder | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . . | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux go build ./cmd/foundry | ||
|
||
FROM archlinux:base-devel-20210124.0.14185 | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /app/foundry . | ||
|
||
EXPOSE 10201 | ||
EXPOSE 10200 | ||
|
||
ENTRYPOINT ["./foundry"] | ||
|
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,66 @@ | ||
include .bingo/Variables.mk | ||
FILES_TO_FMT ?= $(shell find . -path ./vendor -prune -o -name '*.go' -print) | ||
|
||
GO111MODULE ?= on | ||
export GO111MODULE | ||
|
||
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin | ||
|
||
DOCKER_IMAGE_REPO ?= quay.io/prmsrswt/foundry | ||
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))-$(shell date +%Y-%m-%d)-$(shell git rev-parse --short HEAD) | ||
|
||
help: ## Displays help. | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) | ||
|
||
.PHONY: all | ||
all: format build | ||
|
||
.PHONY: build | ||
build: ## Build foundry. | ||
@echo ">> building foundry" | ||
@go build ./cmd/foundry | ||
|
||
.PHONY: install | ||
install: ## Build and install foundry. | ||
@echo ">> installing foundry" | ||
@go install github.com/prmsrswt/foundry/cmd/foundry | ||
|
||
.PHONY: deps | ||
deps: ## Ensures fresh go.mod and go.sum. | ||
@go mod tidy | ||
@go mod verify | ||
|
||
.PHONY: format | ||
format: ## Formats Go code including imports. | ||
format: $(GOIMPORTS) | ||
@echo ">> formatting code" | ||
@$(GOIMPORTS) -w $(FILES_TO_FMT) | ||
|
||
.PHONY: test | ||
test: ## Runs all Go unit tests. | ||
@echo ">> running unit tests" | ||
@go test -v -timeout=30m $(shell go list ./... | grep -v /vendor/) | ||
|
||
.PHONY: coverage | ||
coverage: ## Create test coverage profile | ||
@echo ">> creating test coverage profile" | ||
@go test -v -covermode=count -coverprofile=coverage.out $(shell go list ./... | grep -v /vendor/) | ||
|
||
.PHONY: lint | ||
lint: ## Runs various static analysis against our code. | ||
lint: $(GOLANGCI_LINT) format deps | ||
@echo ">> examining all of the Go files" | ||
@go vet -stdmethods=false ./... | ||
@echo ">> linting all of the Go files GOGC=${GOGC}" | ||
@$(GOLANGCI_LINT) run | ||
|
||
.PHONY: docker | ||
docker: ## Build Docker image | ||
@echo ">> building docker image 'foundry'" | ||
@docker build -t foundry . | ||
|
||
.PHONY: docker-push | ||
docker-push: ## Pushes 'foundry' docker image to "$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_TAG)". | ||
@echo ">> pushing image" | ||
@docker tag "foundry" "$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_TAG)" | ||
@docker push "$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_TAG)" |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.