Skip to content

Commit 032b76f

Browse files
Add link to workshop_1
Signed-off-by: Steve Coffman <[email protected]>
1 parent bd6d260 commit 032b76f

File tree

2 files changed

+59
-43
lines changed

2 files changed

+59
-43
lines changed

Diff for: Makefile

+57-42
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,80 @@
1+
SHELL := bash
2+
.ONESHELL:
3+
.SHELLFLAGS := -eu -o pipefail -c
4+
.DELETE_ON_ERROR:
5+
MAKEFLAGS += --warn-undefined-variables
6+
MAKEFLAGS += --no-builtin-rules
7+
18
GO11MODULES=on
29
APP?=application
3-
REGISTRY?=gcr.io/images
10+
REGISTRY?=stevenacoffman
411
COMMIT_SHA=$(shell git rev-parse --short HEAD)
5-
6-
12+
VERSION=$(shell git rev-parse HEAD)
13+
BUILD=$(shell date +%FT%T%z)
14+
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"
715

816
.PHONY: build
9-
## build: build the application
10-
build: clean
11-
@echo "Building..."
12-
@go build -o ${APP} main.go
17+
build: clean ## - Build the application
18+
@printf "\033[32m\xE2\x9c\x93 Building your code\n\033[0m"
19+
go build -o ${APP} main.go
1320

1421
.PHONY: run
15-
## run: runs go run main.go
16-
run:
22+
run: build ## - Runs go run main.go
23+
@printf "\033[32m\xE2\x9c\x93 Running your code\n\033[0m"
1724
go run -race main.go
1825

1926
.PHONY: clean
20-
## clean: cleans the binary
21-
clean:
22-
@echo "Cleaning"
23-
@rm -rf ${APP}
24-
@go get -u -v golang.org/x/tools/cmd/goimports
25-
@gofmt -l -w -s .
26-
@goimports -l -w .
27+
clean: ## - Cleans the binary
28+
@printf "\033[32m\xE2\x9c\x93 Cleaning your code\n\033[0m"
29+
rm -rf ${APP}
30+
go get -u -v golang.org/x/tools/cmd/goimports
31+
gofmt -l -w -s .
32+
goimports -l -w .
33+
go mod tidy
2734

2835
.PHONY: test
29-
## test: runs go test with default values
30-
test:
36+
test: ## - Runs go test with default values
37+
@printf "\033[32m\xE2\x9c\x93 Testing your code to find potential problems\n\033[0m"
3138
go test -v -count=1 -race ./...
3239

40+
.PHONY: cover
41+
cover: test ## - Runs test coverage report
42+
@printf "\033[32m\xE2\x9c\x93 Running Code Test Coverage Report\n\033[0m"
43+
go test -count=1 -coverprofile=coverage.out
44+
go tool cover -html=coverage.out
45+
3346
.PHONY: lint
34-
## lint: lint the application code for problems
35-
lint:
36-
@golangci-lint run
47+
lint: clean ## - Lint the application code for problems and nits
48+
@printf "\033[32m\xE2\x9c\x93 Linting your code to find potential problems\n\033[0m"
49+
golangci-lint run
3750

38-
.PHONY: setup
39-
## setup: setup go modules
40-
setup:
41-
@go mod init \
42-
&& go mod tidy \
43-
&& go mod vendor
51+
.PHONY: docker-build
52+
docker-build: ## - Build the smallest secure golang docker image based on distroless static
53+
@printf "\033[32m\xE2\x9c\x93 Build the smallest and secured golang docker image based on distroless static\n\033[0m"
54+
docker build -f Dockerfile -t ${REGISTRY}/${APP}:${COMMIT_SHA} .
4455

45-
# helper rule for deployment
46-
check-environment:
47-
ifndef ENV
48-
$(error ENV not set, allowed values - `staging` or `production`)
49-
endif
56+
.PHONY: docker-build-no-cache
57+
docker-build-no-cache: ## - Build the smallest secure golang docker image based on distroless static with no cache
58+
@printf "\033[32m\xE2\x9c\x93 Build the smallest and secured golang docker image based on scratch\n\033[0m"
59+
docker build --no-cache -f Dockerfile -t ${REGISTRY}/${APP}:${COMMIT_SHA} .
5060

51-
.PHONY: docker-build
52-
## docker-build: builds the stringifier docker image to registry
53-
docker-push: build
54-
docker build -t ${APP}:${COMMIT_SHA} .
61+
.PHONY: ls
62+
ls: ## - List size docker images
63+
@printf "\033[32m\xE2\x9c\x93 Look at the size dude !\n\033[0m"
64+
@echo image ls ${REGISTRY}/${APP}
65+
docker image ls ${REGISTRY}/${APP}
66+
67+
.PHONY: docker-run
68+
docker-run: docker-build ## - Run the smallest and secured golang docker image based on distroless static nonroot
69+
@printf "\033[32m\xE2\x9c\x93 Run the smallest and secured golang docker image based on scratch\n\033[0m"
70+
docker run -p 127.0.0.1:8080:8080/tcp ${REGISTRY}/${APP}:${COMMIT_SHA}
5571

5672
.PHONY: docker-push
57-
## docker-push: pushes the stringifier docker image to registry
58-
docker-push: check-environment docker-build
59-
docker push ${REGISTRY}/${ENV}/${APP}:${COMMIT_SHA}
73+
docker-push: docker-build ## - Pushes the docker image to registry
74+
docker push ${REGISTRY}/${APP}:${COMMIT_SHA}
6075

6176
.PHONY: help
6277
## help: Prints this help message
63-
help:
64-
@echo "Usage: \n"
65-
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
78+
help: ## - Show help message
79+
@printf "\033[32m\xE2\x9c\x93 usage: make [target]\n\n\033[0m"
80+
grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ A2 Go, the developer meetup, is a forum for people working in or around Ann Arbo
2121

2222
While each workshop is written with a user group meeting in mind, it could be used in another format. The git repository is structured such that you change branches for each workshop. The zero branch is a very basic hello world web application. Each branch has its own README which walks the attendee through steps to build whatever is being built in that workshop. Subsequent branches pick up where the previous workshop left off. Our goal is for someone with little to no Go experience to be able to start this workshop at step zero.
2323

24-
To get started, clone this repo and change to the [workshop_0](https://github.com/a2go/web-workshop/tree/workshop_0) branch.
24+
To get started at the beginning, clone this repo and change to the [workshop_0](https://github.com/a2go/web-workshop/tree/workshop_0) branch.
25+
To start with a basic webserver, clone this repo and change to the [workshop_1](https://github.com/a2go/web-workshop/tree/workshop_1) branch.

0 commit comments

Comments
 (0)