This repository has been archived by the owner on Nov 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
56 lines (44 loc) · 1.78 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
56
# Running a command like this will push tags like base_123, development_123, and
# production_123 to the private repo:
#
# DOCKER_IMAGE_TAG=123 DOCKER_PUBLISH_PREFIX=repo.name.here/username make
.PHONY: base_container production_container docker
# The name of the image created by this project
DOCKER_IMAGE = ds-auth
ifndef DOCKER_PUBLISH_PREFIX
# Default tag is oskarpearson/${DOCKER_IMAGE}/${DOCKER_IMAGE}:tagvalue
DOCKER_PUBLISH_PREFIX = oskarpearson
endif
ifndef DOCKER_IMAGE_TAG
DOCKER_IMAGE_TAG = localbuild
endif
# Default: tag and push containers
all: build_all_containers tag push
@echo Build Complete
# Improve cacheability by forcing the timestamps of all files to be consistent across builds
force_filesystem_timestamps:
find . -not -iwholename '*.git*' -exec touch -t 200001010000.00 {} \;
# Build all docker containers
build_all_containers: force_filesystem_timestamps base_container test_container
base_container:
docker build -t "${DOCKER_IMAGE}:production_${DOCKER_IMAGE_TAG}" .
test_container: base_container
docker build -t "${DOCKER_IMAGE}:test_${DOCKER_IMAGE_TAG}" .
# Tag repos
tag:
ifeq (${DOCKER_IMAGE_TAG}, localbuild)
@echo Not tagging localbuild containers
else
docker tag -f "${DOCKER_IMAGE}:base_${DOCKER_IMAGE_TAG}" "${DOCKER_PUBLISH_PREFIX}/${DOCKER_IMAGE}:base_${DOCKER_IMAGE_TAG}"
docker tag -f "${DOCKER_IMAGE}:test_${DOCKER_IMAGE_TAG}" "${DOCKER_PUBLISH_PREFIX}/${DOCKER_IMAGE}:test_${DOCKER_IMAGE_TAG}"
@echo Tagged successfully
endif
# Push tagged repos to the registry
push:
ifeq (${DOCKER_IMAGE_TAG}, localbuild)
@echo Not pushing localbuild containers
else
docker push "${DOCKER_PUBLISH_PREFIX}/${DOCKER_IMAGE}:base_${DOCKER_IMAGE_TAG}"
docker push "${DOCKER_PUBLISH_PREFIX}/${DOCKER_IMAGE}:test_${DOCKER_IMAGE_TAG}"
@echo Pushed successfully
endif