-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (81 loc) · 2.25 KB
/
Copy pathMakefile
File metadata and controls
103 lines (81 loc) · 2.25 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
ifndef WEBSITE
WEBSITE := svef.is
endif
ifndef APP
APP := svef-is
endif
ifndef DOCKER_USERNAME
DOCKER_USERNAME := _
endif
ifndef DOCKER_PASSWORD
DOCKER_PASSWORD := $(shell heroku auth:token)
endif
ifndef DOCKER_REGISTRY
DOCKER_REGISTRY := registry.heroku.com
endif
ifndef DOCKER_TAG_VERSION
DOCKER_TAG_VERSION := $(shell git rev-parse --short HEAD)
endif
ifndef DOCKER_IMAGE
DOCKER_IMAGE := ${DOCKER_REGISTRY}/${APP}/web:${DOCKER_TAG_VERSION}
endif
##
## Welcome young Padawan!
## This output should give you some insight into what you can do from here. For more detailed
## overview/instructions/troubleshooting, please checkout .github/CONTRIBUTION_GUIDELINES.md.
##
## --- HELP
help: # This help dialog
@./.utils/help.js
@make debug
debug: # print out all the environment variables as they will be used by other commands
@printf "\
WEBSITE: ${WEBSITE} \n\
APP: ${APP} \n\
DOCKER_USERNAME: ${DOCKER_USERNAME} \n\
DOCKER_PASSWORD: ${DOCKER_PASSWORD} \n\
DOCKER_REGISTRY: ${DOCKER_REGISTRY} \n\
DOCKER_TAG_VERSION: ${DOCKER_TAG_VERSION} \n\
DOCKER_IMAGE: ${DOCKER_IMAGE} \n"
login: # Log into the docker registry with provided credentials
docker login \
-u "${DOCKER_USERNAME}" \
-p "${DOCKER_PASSWORD}" \
${DOCKER_REGISTRY}
##
## --- Project container
.PHONY: build
build: # Build the container with appropriate tags etc
docker build \
-f ./websites/${WEBSITE}/Dockerfile \
--build-arg MONGODB_URI=$MONGODB_URI \
-t ${DOCKER_IMAGE} \
.
test: # Run the tests inside the container
docker run \
--rm -it \
${DOCKER_IMAGE} \
yarn test
run: # Run the latest container
docker run \
--rm -it \
-p 5000:5000 \
${DOCKER_IMAGE}
deploy: # Deploy by pushing the latest image to the registry
docker push \
${DOCKER_IMAGE}
shell: # Open a bash shell within the container (ctrl+d to exit)
docker run \
--rm -it \
${DOCKER_IMAGE} \
bash
##
## --- Shorthands
publish-svef: # build and deploy svef.is
WEBSITE=svef.is APP=www-svef-is make build deploy
publish-skraning: # build and deploy skraning.vefverdlaun.is
WEBSITE=skraning.vefverdlaun.is APP=skraning-vefverdlaun-is make build deploy
publish-members: # build and deploy members.svef.is
WEBSITE=members.svef.is APP=members-svef-is make build deploy
##
## --- Environment variables