2023-01-01 08:45:39 +00:00
|
|
|
MAKE = "make"
|
|
|
|
INSTALL = "install"
|
|
|
|
TAR = "tar"
|
|
|
|
GREP = "grep"
|
|
|
|
NODE = "node"
|
|
|
|
NPM = "npm"
|
|
|
|
NODEJQ = "node_modules/node-jq/bin/jq"
|
|
|
|
SQLITE = "sqlite3"
|
|
|
|
CONF = "src/config.json"
|
|
|
|
PHP = "php"
|
|
|
|
CURL = "curl"
|
2023-08-27 09:26:34 +00:00
|
|
|
DESTDIR = $(shell $(CURDIR)/$(NODEJQ) -r '.dest // "" | select(. != "") // "dist"' $(CURDIR)/$(CONF))
|
2023-01-01 08:45:39 +00:00
|
|
|
SITEDOMAIN = $(shell $(CURDIR)/$(NODEJQ) -r ".DOMAIN" $(CURDIR)/$(CONF))
|
|
|
|
FILESDOMAIN = $(shell $(CURDIR)/$(NODEJQ) -r ".FILE_DOMAIN" $(CURDIR)/$(CONF))
|
2023-01-01 10:27:49 +00:00
|
|
|
MAXSIZE = $(shell $(CURDIR)/$(NODEJQ) -r ".max_upload_size" $(CURDIR)/$(CONF))
|
2023-01-01 08:45:39 +00:00
|
|
|
CONTACT_EMAIL = $(shell $(CURDIR)/$(NODEJQ) -r ".infoContact" $(CURDIR)/$(CONF))
|
2022-07-16 06:24:58 +00:00
|
|
|
PKG_VERSION = $(shell $(CURDIR)/$(NODEJQ) -r ".version" $(CURDIR)/package.json)
|
2023-01-01 12:07:08 +00:00
|
|
|
EXPIRE_TIME = $(shell $(CURDIR)/$(NODEJQ) -r ".expireTime" $(CURDIR)/$(CONF))
|
2022-07-22 04:32:52 +00:00
|
|
|
TMPDIR = $(shell mktemp -d)
|
2022-04-07 09:37:49 +00:00
|
|
|
DOCKER_IMAGE = "$(shell basename $(CURDIR) | tr [:upper:] [:lower:])"
|
2023-01-01 08:45:39 +00:00
|
|
|
DOCKER_TAG = "$(DOCKER_TAG)"
|
|
|
|
CONTAINER_NAME = "$(CONTAINER_NAME)"
|
2022-07-16 06:24:58 +00:00
|
|
|
pageList = $(shell $(CURDIR)/$(NODEJQ) -r ".pages[]" $(CURDIR)/$(CONF))
|
|
|
|
noExt = $(shell echo $(i) | cut -d '.' -f1)
|
|
|
|
|
2023-09-09 13:45:57 +00:00
|
|
|
all: builddirs npm_dependencies ejs minify copy-img copy-php
|
2022-07-16 06:24:58 +00:00
|
|
|
|
|
|
|
ejs:
|
|
|
|
$(foreach i,$(pageList), \
|
2023-01-01 08:45:39 +00:00
|
|
|
"node_modules/ejs/bin/cli.js" -f $(CURDIR)/$(CONF) $(CURDIR)/src/templates/$(i) -o $(CURDIR)/build/html/unmin/$(noExt).html;)
|
2020-11-18 11:54:47 +00:00
|
|
|
|
2023-09-09 13:45:57 +00:00
|
|
|
minify:
|
2023-09-09 13:57:49 +00:00
|
|
|
"node_modules/@node-minify/cli/dist/cli.mjs" --compressor uglify-es --input $(CURDIR)/src/static/js/uguu.js --output $(CURDIR)/build/js/uguu.min.js
|
|
|
|
"node_modules/@node-minify/cli/dist/cli.mjs" --compressor cssnano --input $(CURDIR)/src/static/css/uguu.css --output $(CURDIR)/build/css/uguu.min.css
|
|
|
|
"node_modules/@node-minify/cli/dist/cli.mjs" --compressor html-minifier --input $(CURDIR)/build/html/unmin/faq.html --output $(CURDIR)/build/html/min/faq.html
|
|
|
|
"node_modules/@node-minify/cli/dist/cli.mjs" --compressor html-minifier --input $(CURDIR)/build/html/unmin/api.html --output $(CURDIR)/build/html/min/api.html
|
|
|
|
"node_modules/@node-minify/cli/dist/cli.mjs" --compressor html-minifier --input $(CURDIR)/build/html/unmin/index.html --output $(CURDIR)/build/html/min/index.html
|
2020-11-18 11:54:47 +00:00
|
|
|
|
|
|
|
installdirs:
|
|
|
|
mkdir -p $(DESTDIR)/ $(DESTDIR)/img
|
2022-01-22 02:19:57 +00:00
|
|
|
mkdir -p $(DESTDIR)/ $(DESTDIR)/img/grills
|
2020-11-18 11:54:47 +00:00
|
|
|
|
|
|
|
copy-img:
|
2023-01-01 08:45:39 +00:00
|
|
|
"node_modules/imagemin-cli/cli.js" $(CURDIR)/src/static/img/*.png -o=$(CURDIR)/build/img/
|
|
|
|
"node_modules/imagemin-cli/cli.js" $(CURDIR)/src/static/img/grills/*.png --plugin=pngquant -o=$(CURDIR)/build/img/grills/
|
|
|
|
|
2020-11-18 11:54:47 +00:00
|
|
|
|
|
|
|
copy-php:
|
2022-07-22 04:32:52 +00:00
|
|
|
cp -v $(CURDIR)/src/static/php/*.php $(CURDIR)/build/php/
|
2022-12-16 21:53:50 +00:00
|
|
|
cp -v $(CURDIR)/src/Classes/*.php $(CURDIR)/build/php/Classes/
|
2020-11-18 11:54:47 +00:00
|
|
|
|
|
|
|
install: installdirs
|
2023-08-02 19:32:29 +00:00
|
|
|
rm -rf $(DESTDIR)/*
|
2020-11-18 11:54:47 +00:00
|
|
|
cp -rv $(CURDIR)/build/* $(DESTDIR)/
|
2022-12-16 21:11:57 +00:00
|
|
|
cp $(CURDIR)/src/*.json $(DESTDIR)/
|
2022-12-16 19:44:43 +00:00
|
|
|
mv $(DESTDIR)/html/min/* $(DESTDIR)/public/
|
|
|
|
mv $(DESTDIR)/js/* $(DESTDIR)/public/
|
|
|
|
mv $(DESTDIR)/css/* $(DESTDIR)/public/
|
2022-07-22 04:32:52 +00:00
|
|
|
mv $(DESTDIR)/php/* $(DESTDIR)/
|
2022-07-16 06:24:58 +00:00
|
|
|
rm -rf $(DESTDIR)/html
|
|
|
|
rm -rf $(DESTDIR)/css
|
|
|
|
rm -rf $(DESTDIR)/js
|
2022-07-22 04:32:52 +00:00
|
|
|
rm -rf $(DESTDIR)/php
|
2022-12-16 19:44:43 +00:00
|
|
|
mv $(DESTDIR)/img $(DESTDIR)/public/
|
|
|
|
mv $(DESTDIR)/grill.php $(DESTDIR)/public/
|
|
|
|
mv $(DESTDIR)/upload.php $(DESTDIR)/public/
|
2022-12-16 21:11:57 +00:00
|
|
|
cd $(DESTDIR)/ && $(CURL) -o composer-setup.php https://raw.githubusercontent.com/composer/getcomposer.org/main/web/installer
|
|
|
|
cd $(DESTDIR)/ && $(PHP) composer-setup.php --quiet
|
|
|
|
cd $(DESTDIR)/ && rm composer-setup.php
|
|
|
|
cd $(DESTDIR)/ && php composer.phar update && php composer.phar install && php composer.phar dump-autoload
|
2022-07-22 04:32:52 +00:00
|
|
|
|
2020-11-18 11:54:47 +00:00
|
|
|
dist:
|
|
|
|
DESTDIR=$(TMPDIR)/uguu-$(PKGVERSION)
|
|
|
|
export DESTDIR
|
|
|
|
install
|
|
|
|
$(TAR) cJf uguu-$(PKG_VERSION).tar.xz $(DESTDIR)
|
|
|
|
rm -rf $(TMPDIR)
|
2023-01-01 08:45:39 +00:00
|
|
|
|
2022-07-22 04:32:52 +00:00
|
|
|
|
2020-11-18 11:54:47 +00:00
|
|
|
clean:
|
2023-01-01 08:45:39 +00:00
|
|
|
rm -rvf $(CURDIR)/node_modules
|
2020-11-18 11:54:47 +00:00
|
|
|
rm -rvf $(CURDIR)/build
|
2023-01-01 08:45:39 +00:00
|
|
|
|
2022-07-22 04:32:52 +00:00
|
|
|
|
2020-11-18 11:54:47 +00:00
|
|
|
uninstall:
|
|
|
|
rm -rvf $(DESTDIR)/
|
2023-01-01 08:45:39 +00:00
|
|
|
|
2022-07-22 04:32:52 +00:00
|
|
|
|
2020-11-18 11:54:47 +00:00
|
|
|
npm_dependencies:
|
|
|
|
$(NPM) install
|
|
|
|
|
2023-01-01 08:45:39 +00:00
|
|
|
build-container-no-cache:
|
2023-01-01 10:48:19 +00:00
|
|
|
tar --exclude='uguuForDocker.tar.gz' --exclude='vendor' --exclude='node_modules' --exclude='build' --exclude='dist' --exclude='.git' -czf uguuForDocker.tar.gz src docker Makefile package.json package-lock.json
|
2022-07-22 04:32:52 +00:00
|
|
|
mv uguuForDocker.tar.gz docker/
|
2023-01-01 12:11:16 +00:00
|
|
|
docker build -f docker/Dockerfile --build-arg DOMAIN=$(SITEDOMAIN) --build-arg FILE_DOMAIN=$(FILESDOMAIN) --build-arg CONTACT_EMAIL=$(CONTACT_EMAIL) --build-arg MAX_SIZE=$(MAXSIZE) --build-arg EXPIRE_TIME=$(EXPIRE_TIME) --no-cache -t uguu:$(PKG_VERSION) .
|
2023-01-01 08:45:39 +00:00
|
|
|
|
|
|
|
build-container:
|
2023-01-01 10:48:19 +00:00
|
|
|
tar --exclude='uguuForDocker.tar.gz' --exclude='vendor' --exclude='node_modules' --exclude='build' --exclude='dist' --exclude='.git' -czf uguuForDocker.tar.gz src docker Makefile package.json package-lock.json
|
2023-01-01 08:45:39 +00:00
|
|
|
mv uguuForDocker.tar.gz docker/
|
2023-01-01 12:11:16 +00:00
|
|
|
docker build -f docker/Dockerfile --build-arg DOMAIN=$(SITEDOMAIN) --build-arg FILE_DOMAIN=$(FILESDOMAIN) --build-arg CONTACT_EMAIL=$(CONTACT_EMAIL) --build-arg MAX_SIZE=$(MAXSIZE) --build-arg EXPIRE_TIME=$(EXPIRE_TIME) -t uguu:$(PKG_VERSION) .
|
2022-04-07 09:37:49 +00:00
|
|
|
|
|
|
|
run-container:
|
2023-01-01 10:06:29 +00:00
|
|
|
docker run --name uguu -d -p 80:80 -p 443:443 uguu:$(PKG_VERSION)
|
2022-04-07 09:37:49 +00:00
|
|
|
|
2023-01-01 08:45:39 +00:00
|
|
|
purge-containers:
|
|
|
|
if docker images | grep uguu; then \
|
|
|
|
docker rm -f uguu && docker rmi uguu:$(PKG_VERSION) || true;\
|
2022-04-07 09:37:49 +00:00
|
|
|
fi;
|
|
|
|
|
2023-01-01 08:45:39 +00:00
|
|
|
remove-container:
|
|
|
|
docker rm -f uguu
|
|
|
|
|
2020-11-18 11:54:47 +00:00
|
|
|
builddirs:
|
2022-12-16 21:53:50 +00:00
|
|
|
mkdir -p $(CURDIR)/build $(CURDIR)/build/img $(CURDIR)/build/html $(CURDIR)/build/html/min $(CURDIR)/build/html/unmin $(CURDIR)/build/js $(CURDIR)/build/css $(CURDIR)/build/php $(CURDIR)/build/php/Classes $(CURDIR)/build/public
|
2022-07-22 04:32:52 +00:00
|
|
|
|