This repository has been archived by the owner on Apr 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
55 lines (41 loc) · 1.77 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
SIZE ?= 4
PORT ?= 2000
CONTAINER_NAME := 15-puzzle-go
DOCKER := docker run -it --rm -v "${PWD}/src:/src" $(CONTAINER_NAME)
DOCKER_WEBSERVER := docker run -it --rm -v "${PWD}/src:/src" -p $(PORT):$(PORT) $(CONTAINER_NAME)
DOCKERFILE_NAME_PROD := DockerfileProd.docker
CONTAINER_NAME_PROD := 15-puzzle-api
REPOSITORY_NAME_PROD := luwangel
DOCKER_PROD := docker run -it --rm $(CONTAINER_NAME_PROD)
DOCKER_WEBSERVER_PROD := docker run -it --rm -p $(PORT):$(PORT) $(CONTAINER_NAME_PROD)
help: ## Print all commands (default)
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
####### BUILD #######
build-docker: ## Build the dev docker
ifeq ($(ENV), prod)
docker build -f $(DOCKERFILE_NAME_PROD) -t $(REPOSITORY_NAME_PROD)/$(CONTAINER_NAME_PROD) .
else
docker build -t $(CONTAINER_NAME) .
endif
install: build-docker ## Build the dev docker (alias for `build-docker`)
install-prod: build-docker-prod ## Build the prod docker (alias for `build-docker` with prod env)
publish: build-docker-prod ## Publish the docker in the dockerhub. Be careful, you should be logged before!
docker push $(REPOSITORY_NAME_PROD)/$(CONTAINER_NAME_PROD)
####### RUN #######
run: ## Run the 15-puzzle game with the env variable SIZE as parameter
ifeq ($(ENV), prod)
$(DOCKER_PROD) go run main/main.go --size=$(SIZE)
else
$(DOCKER) go run main/main.go --size=$(SIZE)
endif
run-server: ## Run the 15-puzzle webserver at port (default: 2000)
ifeq ($(ENV), prod)
$(DOCKER_WEBSERVER_PROD) go run main/main-server.go --port=$(PORT)
else
$(DOCKER_WEBSERVER) go run main/main-server.go --port=$(PORT)
endif
####### DEV #######
test: ## Run all tests
$(DOCKER) go test -v ./...
lint: ## Run the gofmt linter
$(DOCKER) gofmt -w .