-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
55 lines (44 loc) · 1.75 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
DOCKERHUB_REPO := taccwma/$(shell cat ./docker_repo.var)
DOCKER_TAG ?= $(shell git rev-parse --short HEAD)
DOCKER_IMAGE := $(DOCKERHUB_REPO):$(DOCKER_TAG)
DOCKER_IMAGE_LATEST := $(DOCKERHUB_REPO):latest
# WARNING: Using `docker-compose` is deprecated
DOCKER_COMPOSE_CMD := $(shell if command -v docker-compose > /dev/null; then echo "docker-compose"; else echo "docker compose"; fi)
# NOTE: The `DOCKER_IMAGE_BRANCH` tag is the git tag for the commit if it exists, else the branch on which the commit exists.
# NOTE: Special characters in `DOCKER_IMAGE_BRANCH` are replaced with dashes.
DOCKER_IMAGE_BRANCH := $(DOCKERHUB_REPO):$(shell git describe --exact-match --tags 2> /dev/null || git symbolic-ref --short HEAD | sed 's/[^[:alnum:]\.\_\-]/-/g')
PROJECT_NAME := $(shell cat ./project_name.var)
NEEDS_DEMO := $(shell cat ./needs_demo.var)
BUILD_ID := $(shell git describe --always)
.PHONY: build
build:
$(DOCKER_COMPOSE_CMD) -f ./docker-compose.yml build
.PHONY: build-full
build-full:
docker build -t $(DOCKER_IMAGE) \
--target production \
--build-arg PROJECT_NAME="$(PROJECT_NAME)" \
--build-arg BUILD_ID="$(BUILD_ID)" \
--build-arg NEEDS_DEMO="$(NEEDS_DEMO)" \
-f ./Dockerfile .
docker tag $(DOCKER_IMAGE) $(DOCKER_IMAGE_BRANCH)
.PHONY: example
example:
$(DOCKER_COMPOSE_CMD) -f ./docker-compose.example.yml up
.PHONY: publish
publish:
docker push $(DOCKER_IMAGE)
docker push $(DOCKER_IMAGE_BRANCH)
.PHONY: publish-latest
publish-latest:
docker tag $(DOCKER_IMAGE) $(DOCKER_IMAGE_LATEST)
docker push $(DOCKER_IMAGE_LATEST)
.PHONY: start
start:
$(DOCKER_COMPOSE_CMD) -f docker-compose.dev.yml up
.PHONY: stop
stop:
$(DOCKER_COMPOSE_CMD) -f docker-compose.dev.yml down
.PHONY: stop-verbose
stop-v:
$(DOCKER_COMPOSE_CMD) -f docker-compose.dev.yml down -v