Skip to content

Commit

Permalink
Added Makefile and Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
oscaromeu committed Feb 28, 2021
1 parent e3dc984 commit 3c86dbd
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions examples/influxdb/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
VERSION=`git rev-parse HEAD`
BUILD=`date +%FT%T%z`
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"
DOCKER_IMAGE=meteocat-testing
DOCKER_IMAGE_TAG=meteocat-testing
PLATFORM=local

.PHONY: help
help: ## - Show help message
@printf "\033[32m\xE2\x9c\x93 usage: make [target]\n\n\033[0m"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: docker-pull
docker-pull: ## - docker pull latest images
@printf "\033[32m\xE2\x9c\x93 docker pull latest images\n\033[0m"
@docker pull golang:alpine

.PHONY: docker-pull-distroless
docker-pull-distroless: ## - docker pull latest images
@printf "\033[32m\xE2\x9c\x93 docker pull latest images\n\033[0m"
@docker pull golang:buster
@docker pull gcr.io/distroless/base
@docker pull gcr.io/distroless/static

.PHONY: build-distroless
build-distroless:docker-pull-distroless ## - Build the smallest and secured golang docker image based on distroless
@printf "\033[32m\xE2\x9c\x93 Build the smallest and secured golang docker image based on distroless\n\033[0m"
$(eval BUILDER_IMAGE=$(shell docker inspect --format='{{index .RepoDigests 0}}' golang:buster))
$(eval DISTROLESS_IMAGE=$(shell docker inspect --format='{{index .RepoDigests 0}}' gcr.io/distroless/base))
@export DOCKER_CONTENT_TRUST=1
@docker build -f Dockerfile --build-arg BUILDER_IMAGE=$(BUILDER_IMAGE) --build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) -t $(DOCKER_IMAGE_TAG)-distroless .

.PHONY: ls
ls: ## - List '$(DOCKER_IMAGE_TAG)' docker images
@printf "\033[32m\xE2\x9c\x93 Look at the size dude !\n\033[0m"
@docker image ls $(DOCKER_IMAGE_TAG)

.PHONY: run
run: ## - Run the smallest and secured golang docker image based on scratch
@printf "\033[32m\xE2\x9c\x93 Run the smallest and secured golang docker image based on scratch\n\033[0m"
@docker run $(DOCKER_IMAGE_TAG):latest

0 comments on commit 3c86dbd

Please sign in to comment.