-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
36 lines (29 loc) · 873 Bytes
/
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
DOCKER_IMAGE_VERSION := 1.0
DOCKER_IMAGE := games-api:v$(DOCKER_IMAGE_VERSION)
CONTAINER_NAME := games-api
SRC := main.go
OUT := gserver
GET_CONTAINER_NAME := $(shell docker container ls -a --format "{{.Names}}" --filter "name=$(CONTAINER_NAME)")
GET_CONTAINER_IMAGE := $(shell docker image ls --format "{{.Repository}}" --filter=reference=$(DOCKER_IMAGE))
ifeq ($(GET_CONTAINER_NAME), $(CONTAINER_NAME))
container-up: image-build
@echo "Container Exists"
else
container-up: image-build
@docker container run -it -d -p 8080:8080 --rm --name $(CONTAINER_NAME) $(DOCKER_IMAGE)
endif
container-down:
@docker container rm -f $(CONTAINER_NAME)
ifneq ($(GET_CONTAINER_IMAGE), $(CONTAINER_NAME))
image-build:
@docker image build -t $(DOCKER_IMAGE) .
else
image-build:
@echo "Image Exists"
endif
build:
@go build -o $(OUT) $(SRC)
run:
@./$(OUT)
clean:
@rm -f $(OUT)