Skip to content

Commit

Permalink
Merge pull request #218 from meshery/leecalcote/security
Browse files Browse the repository at this point in the history
[CI] Makefile improvement and Dockerfile update
  • Loading branch information
leecalcote authored Sep 1, 2022
2 parents 23a6cd0 + b82c90e commit 5fa8d28
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 6 deletions.
62 changes: 56 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,77 @@
protoc-setup:
# Copyright Meshery Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

include build/Makefile.core.mk
include build/Makefile.show-help.mk

#-----------------------------------------------------------------------------
# Environment Setup
#-----------------------------------------------------------------------------
BUILDER=buildx-multi-arch
ADAPTER=traefik-mesh

v ?= 1.17.8 # Default go version to be used


#-----------------------------------------------------------------------------
# Docker-based Builds
#-----------------------------------------------------------------------------
.PHONY: docker docker-run lint proto-setup proto error test run run-force-dynamic-reg


## Lint check Golang
lint:
golangci-lint run

## Retrieve protos
proto-setup:
cd meshes
wget https://raw.githubusercontent.com/layer5io/meshery/master/meshes/meshops.proto

## Generate protos
proto:
protoc -I meshes/ meshes/meshops.proto --go_out=plugins=grpc:./meshes/

## Build Adapter container image with "edge-latest" tag
docker:
docker build -t layer5/meshery-traefik-mesh .
DOCKER_BUILDKIT=1 docker build -t layer5/meshery-$(ADAPTER):$(RELEASE_CHANNEL)-latest .

## Run Adapter container with "edge-latest" tag
docker-run:
(docker rm -f meshery-traefik-mesh) || true
docker run --name meshery-traefik-mesh -d \
-p 10000:10000 \
(docker rm -f meshery-$(ADAPTER)) || true
docker run --name meshery-$(ADAPTER) -d \
-p 10006:10006 \
-e DEBUG=true \
layer5/meshery-traefik-mesh
layer5/meshery-$(ADAPTER):$(RELEASE_CHANNEL)-latest

## Build and run Adapter locally
run:
go$(v) mod tidy -compat=1.17; \
DEBUG=true GOPROXY=direct GOSUMDB=off go run main.go

## Build and run Adapter locally; force component registration
run-force-dynamic-reg:
FORCE_DYNAMIC_REG=true DEBUG=true GOPROXY=direct GOSUMDB=off go run main.go

## Run Meshery Error utility
error:
go run github.com/layer5io/meshkit/cmd/errorutil -d . analyze -i ./helpers -o ./helpers

## Run Golang tests
test:
export CURRENTCONTEXT="$(kubectl config current-context)"
echo "current-context:" ${CURRENTCONTEXT}
export KUBECONFIG="${HOME}/.kube/config"
echo "environment-kubeconfig:" ${KUBECONFIG}
GOPROXY=direct GOSUMDB=off GO111MODULE=on go test -v ./...
50 changes: 50 additions & 0 deletions build/Makefile.core.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright Meshery Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#-----------------------------------------------------------------------------
# Global Variables
#-----------------------------------------------------------------------------
GIT_VERSION = $(shell git describe --tags `git rev-list --tags --max-count=1`)
GIT_COMMITSHA = $(shell git rev-list -1 HEAD)
GIT_STRIPPED_VERSION=$(shell git describe --tags `git rev-list --tags --max-count=1` | cut -c 2-)

GOVERSION = 1.17.8
GOPATH = $(shell go env GOPATH)
GOBIN = $(GOPATH)/bin

SHELL :=/bin/bash -o pipefail

#-----------------------------------------------------------------------------
# Components
#-----------------------------------------------------------------------------
ADAPTER_URLS := "localhost:10000 localhost:10001 localhost:10002 localhost:10004 localhost:10005 localhost:10006 localhost:10007 localhost:10009 localhost:10010 localhost:10012"

#-----------------------------------------------------------------------------
# Providers
#-----------------------------------------------------------------------------
REMOTE_PROVIDER_LOCAL="http://localhost:9876"
MESHERY_CLOUD_DEV="http://localhost:9876"
MESHERY_CLOUD_PROD="https://meshery.layer5.io"
MESHERY_CLOUD_STAGING="https://staging-meshery.layer5.io"

#-----------------------------------------------------------------------------
# Server
#-----------------------------------------------------------------------------
MESHERY_K8S_SKIP_COMP_GEN ?= TRUE
APPLICATIONCONFIGPATH="../install/apps.json"

#-----------------------------------------------------------------------------
# Build
#-----------------------------------------------------------------------------
RELEASE_CHANNEL=edge
5 changes: 5 additions & 0 deletions build/Makefile.show-help.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DEFAULT_GOAL := show-help
# See <https://gist.github.com/klmr/575726c7e05d8780505a> for explanation.
.PHONY: show-help
show-help:
@echo "$$(tput bold)Please specify a build target. The choices are:$$(tput sgr0)";echo;sed -ne"/^## /{h;s/.*//;:d" -e"H;n;s/^## //;td" -e"s/:.*//;G;s/\\n## /---/;s/\\n/ /g;p;}" ${MAKEFILE_LIST}|LC_ALL='C' sort -f|awk -F --- -v n=$$(tput cols) -v i=19 -v a="$$(tput setaf 6)" -v z="$$(tput sgr0)" '{printf"%s%*s%s ",a,-i,$$1,z;m=split($$2,w," ");l=n-i;for(j=1;j<=m;j++){l-=length(w[j])+1;if(l<= 0){l=n-i-length(w[j])-1;printf"\n%*s ",-i," ";}printf"%s ",w[j];}printf"\n";}'|more $(shell test $(shell uname) == Darwin && echo '-Xr')

0 comments on commit 5fa8d28

Please sign in to comment.