This repository has been archived by the owner on Sep 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
project.makefile.example
109 lines (74 loc) · 3.78 KB
/
project.makefile.example
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
104
105
106
107
108
109
###
# This makefile is intended to be a template for custom makefiles which
# set up individual web projects after the server itself is built. But the more
# specific a guide gets, the more likely that it'll need significant rework in order
# for someone else to use it, and this guide is definitely very specific
# to the kind of projects I typically use.
#
# In particular, note that the project is assumed to be using Composer, and that the
# Composer.phar file is not present and needs to be fetched.
#
# So please, read this through to the end, and understand the why's. I've attempted
# to call attention with a TODO note to places you'll definitely need to revise, but do
# understand that these are likely not the only changes you'll need to make.
###
## The name of this project. Used to pick config file names, etc.
PROJECT_NAME = someprojectname ## TODO - change this to something appropriate, with no spaces or punctuation (think file names without the extension)
## The domain name that the generated self-signed-cert should cover.
CERT_DOMAIN = *.somedomain.local ## TODO - can be wildcard like the shown example.
## The cert file name root that the cert files are generated with
CERT_FILE_NAME = $(PROJECT_NAME)
## The password used to generate the cert files - note that this is
# obviously a think which should be kept secure if you ever intend
# to use the self-signed cert in a publicly available site
CERT_PASSWORD = selfsignedpassword
###############################################################################
### Global configuration
SHELL := /usr/bin/env bash
WORKING_DIR = /tmp/makework
TOOL_DIR = $(CURDIR)
all : target-list
target-list :
@echo "This makefile installs this project into a server"
@echo
@echo "Available targets:"
@echo " install"
@echo " install_dev"
@echo
install : nginx_conf install_composer composer_install_dependencies db_init nginx_restart
install_dev : nginx_conf self_signed_cert install_composer composer_install_dependencies_dev db_init nginx_restart
########################################################################
nginx_conf :
cp $(TOOL_DIR)/$(PROJECT_NAME).nginx /etc/nginx/sites-available/$(PROJECT_NAME)
ln -s /etc/nginx/sites-available/$(PROJECT_NAME) /etc/nginx/sites-enabled/$(PROJECT_NAME)
nginx_restart :
service nginx reload
# Be aware that certs generated this way are not very secure
self_signed_cert :
mkdir -p $(WORKING_DIR) && cd $(WORKING_DIR) && \
# \
openssl genrsa -des3 -passout pass:$(CERT_PASSWORD) -out $(CERT_FILE_NAME).key 4096 && \
# \
openssl req -new -passin pass:$(CERT_PASSWORD) -passout pass:$(CERT_PASSWORD) -key $(CERT_FILE_NAME).key -out $(CERT_FILE_NAME).csr \
-subj "/C=US/ST=Calfornia/L=San Francisco/O=No Company/CN=$(CERT_DOMAIN)" && \
# \
openssl rsa -passin pass:$(CERT_PASSWORD) -in $(CERT_FILE_NAME).key -out $(CERT_FILE_NAME).nginx.key && \
# \
openssl x509 -req -passin pass:$(CERT_PASSWORD) -in $(CERT_FILE_NAME).csr -signkey $(CERT_FILE_NAME).nginx.key -out $(CERT_FILE_NAME).nginx.crt -days 365 && \
# \
cp $(CERT_FILE_NAME).nginx.crt /etc/ssl/certs/ && \
cp $(CERT_FILE_NAME).nginx.key /etc/ssl/private/
rm -rf $(WORKING_DIR)
install_composer :
cd ../ && \
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
composer_install_dependencies :
cd ../ && \
./composer.phar install --verbose --prefer-dist -o
composer_install_dependencies_dev :
cd ../ && \
./composer.phar install --verbose --prefer-source --dev
db_init :
## TODO - Your project's database initialization will likely be so custom that it's not
# worth even showing an example here. Speculating, I'd guess you'd call an external
# .sql script with the command-line mysql client.