forked from cybercommons/cybercommons
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
102 lines (78 loc) · 2.64 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
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
dc_config/secrets.env:
# Creating secrets file for editing
ifndef EDITOR
ifeq ($(strip $(shell which nano)),)
$(error dc_config/secrets.env will need to be manually created. Copy dc_config/secrets_template.env as a starting point)
endif
endif
@cp dc_config/secrets_template.env dc_config/secrets.env
@$${EDITOR:-nano} dc_config/secrets.env
include dc_config/cybercom_config.env
include dc_config/secrets.env
# Set GITPOD_PORT to 8080 if run in gitpod
ifneq ($(strip $(GITPOD_WORKSPACE_ID)),)
GITPOD_PORT = 8080
ALLOWED_HOSTS = .gitpod.io,localhost
endif
COMPOSE_INIT = docker-compose -f dc_config/images/docker-compose-init.yml
CERTBOT_INIT = docker-compose -f dc_config/images/certbot-initialization.yml
SHELL = /bin/bash
.PHONY: init intidb initssl cert_dates superuser init_certbot renew_certbot shell apishell dbshell build force_build run stop test restart_api collectstatic
.EXPORT_ALL_VARIABLES:
UID=$(shell id -u)
GID=$(shell id -g)
init:
$(COMPOSE_INIT) build
$(COMPOSE_INIT) up
$(COMPOSE_INIT) down
initdb:
$(COMPOSE_INIT) up cybercom_mongo_init
$(COMPOSE_INIT) down
initssl:
$(COMPOSE_INIT) build cybercom_openssl_init
$(COMPOSE_INIT) up cybercom_openssl_init
$(COMPOSE_INIT) down
cert_dates:
# Show valid date ranges for backend ssl certificates
@$(COMPOSE_INIT) run --rm cybercom_openssl_init openssl x509 -noout -dates -in /ssl/server/cert.pem
superuser:
@docker-compose run --rm cybercom_api ./manage.py createsuperuser
init_certbot:
$(CERTBOT_INIT) build
$(CERTBOT_INIT) up --abort-on-container-exit
$(CERTBOT_INIT) down
renew_certbot:
$(CERTBOT_INIT) run --rm cybercom_certbot
# FIXME: the following is not reloading certs
#@docker-compose exec cybercom_nginx nginx -s reload
# This is a work around until the reload signal is fixed
@docker-compose restart cybercom_nginx
shell:
@echo "Loading new shell with configured environment"
@$(SHELL)
apishell:
@echo "Launching shell into Django"
@docker-compose exec cybercom_api python manage.py shell
dbshell:
@echo "Launching shell into MongoDB"
@docker-compose exec cybercom_mongo mongo admin \
--tls \
--host cybercom_mongo \
--tlsCertificateKeyFile /ssl/client/mongodb.pem \
--tlsCAFile /ssl/testca/cacert.pem \
--username $$MONGO_USERNAME \
--password $$MONGO_PASSWORD
build:
@docker-compose --compatibility build
force_build:
@docker-compose --compatibility build --no-cache
run:
@docker-compose --compatibility up -d
stop:
@docker-compose --compatibility down
test:
@docker-compose exec cybercom_api python -Wa manage.py test
restart_api:
@docker-compose restart cybercom_api
collectstatic:
@docker-compose run --rm cybercom_api ./manage.py collectstatic --noinput