aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThedro Neely <thedroneely@gmail.com>2022-11-16 03:46:30 -0500
committerThedro Neely <thedroneely@gmail.com>2022-11-16 07:03:30 -0500
commita2f16246ec362f8a00ad4eedf2f7aea565e6d488 (patch)
tree25ba5fdc4bb291efe95022b8ac579d9b94d0a067
parentb2c05f03749d8e69f5909737b18425772bcb784b (diff)
downloadedwinmattiacci.com-a2f16246ec362f8a00ad4eedf2f7aea565e6d488.tar.gz
edwinmattiacci.com-a2f16246ec362f8a00ad4eedf2f7aea565e6d488.tar.bz2
edwinmattiacci.com-a2f16246ec362f8a00ad4eedf2f7aea565e6d488.zip
Makefile: Add deployment logic
-rw-r--r--.gitignore3
-rw-r--r--Makefile56
-rw-r--r--database/contactform.sql7
-rw-r--r--[-rwxr-xr-x]public/dist/soundmanager2-nodebug-jsmin.js0
4 files changed, 66 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 6d19387..05ddf83 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,5 +3,8 @@
/public/posts
/vendor
config.php
+database
generators/hugo/public
google[a-z0-9]*.html
+production
+staging
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..761bd96
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,56 @@
+all:
+ make site
+ make migration
+
+site:
+ mkdir --parents public/posts
+ ln -sfT ../../public/posts generators/hugo/public
+ cd generators/hugo && hugo
+
+migration:
+ sqlite3 database/sqlite.db < database/contactform.sql
+ chmod g+w database/sqlite.db
+ sed --in-place "s|'sql:;dbname=sql_database'|'sqlite:' . __DIR__ . '/database/sqlite.db'|" config.php
+
+permissions:
+ find . -type f -print0 | xargs -0 chmod 640
+ find . -type d -print0 | xargs -0 chmod 770
+
+export date := $(shell date -Iseconds)
+export path := deploy-$(date)
+export deployment := $(target)/$(path)
+export prelaunch := $(target)/prelaunch
+export public := $(target)/public
+
+deploy:
+ mkdir --parent '$(deployment)'
+ rsync --archive --verbose \
+ --exclude='.git/' \
+ --exclude='.gitignore' \
+ --exclude='$(target)/' \
+ . '$(deployment)'
+ ln --symbolic --force '$(path)/public' '$(prelaunch)'
+ make minify
+ make cache
+ cd '$(deployment)' && make site && make migration
+ make permissions
+ mv --force --no-target-directory '$(prelaunch)' '$(public)'
+ find '$(target)' -maxdepth 1 ! -path '$(target)' -type d -printf '%T@\t%p\n' \
+ | sort --reverse --general-numeric-sort --field-separator $$'\t' \
+ | cut --delimiter $$'\t' --fields 2- \
+ | awk "NR>5" \
+ | xargs rm -rf
+
+cache:
+ { [ -e '$(public)' ] \
+ && rsync --verbose --archive --include="*/" --include="*.min.*" --exclude="*" '$(public)/dist/' '$(prelaunch)/dist'; } || true
+
+minify:
+ minify $(prelaunch)/dist/app.css > $(prelaunch)/dist/app.min.'$(date)'.css
+ minify $(prelaunch)/dist/bar-ui.css > $(prelaunch)/dist/bar-ui-css.min.'$(date)'.css
+ minify $(prelaunch)/dist/bar-ui.js > $(prelaunch)/dist/bar-ui-js.min.'$(date)'.js
+ find $(prelaunch) -type f -exec sed --in-place "s|$$(find $(prelaunch)/dist -name "app.min*" | awk -F/ '{print $NF}')|" {} \;
+ find $(prelaunch) -type f -exec sed --in-place "s|$$(find $(prelaunch)/dist -name "bar-ui-css.min*" | awk -F/ '{print $NF}')|" {} \;
+ find $(prelaunch) -type f -exec sed --in-place "s|$$(find $(prelaunch)/dist -name "bar-ui-js.min*" | awk -F/ '{print $NF}')|" {} \;
+
+.PHONY: generators admin
diff --git a/database/contactform.sql b/database/contactform.sql
new file mode 100644
index 0000000..196cd9b
--- /dev/null
+++ b/database/contactform.sql
@@ -0,0 +1,7 @@
+CREATE TABLE IF NOT EXISTS contactform (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ name TEXT,
+ email TEXT NOT NULL,
+ message TEXT NOT NULL,
+ date TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
+);
diff --git a/public/dist/soundmanager2-nodebug-jsmin.js b/public/dist/soundmanager2-nodebug-jsmin.js
index 3f2d704..3f2d704 100755..100644
--- a/public/dist/soundmanager2-nodebug-jsmin.js
+++ b/public/dist/soundmanager2-nodebug-jsmin.js