From 3b940afe60766515adaab1a036a0386874d8afe1 Mon Sep 17 00:00:00 2001 From: "Go Johansson (neku)" Date: Sun, 1 Jan 2023 12:53:42 +0100 Subject: [PATCH] fixes --- Makefile | 5 +++-- docker/Dockerfile | 10 ++++++++++ src/config.json | 2 +- src/static/scripts/checkdb.sh | 2 +- src/static/scripts/checkfiles.sh | 1 + src/templates/partials/lead.ejs | 2 +- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 61a12b7..f6b8331 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ FILESDOMAIN = $(shell $(CURDIR)/$(NODEJQ) -r ".FILE_DOMAIN" $(CURDIR)/$(CONF)) MAXSIZE = $(shell $(CURDIR)/$(NODEJQ) -r ".max_upload_size" $(CURDIR)/$(CONF)) CONTACT_EMAIL = $(shell $(CURDIR)/$(NODEJQ) -r ".infoContact" $(CURDIR)/$(CONF)) PKG_VERSION = $(shell $(CURDIR)/$(NODEJQ) -r ".version" $(CURDIR)/package.json) +EXPIRE_TIME = $(shell $(CURDIR)/$(NODEJQ) -r ".expireTime" $(CURDIR)/package.json) TMPDIR = $(shell mktemp -d) DOCKER_IMAGE = "$(shell basename $(CURDIR) | tr [:upper:] [:lower:])" DOCKER_TAG = "$(DOCKER_TAG)" @@ -90,12 +91,12 @@ npm_dependencies: build-container-no-cache: 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 mv uguuForDocker.tar.gz docker/ - docker build -f docker/Dockerfile --build-arg VERSION=$(PKG_VERSION) --no-cache -t uguu:$(PKG_VERSION) . + docker build -f docker/Dockerfile --build-arg DOMAIN=$(SITEDOMAIN) --build-arg FILE_DOMAIN=$(FILESDOMAIN) --build-arg CONTACT_EMAIL=$(FILESDOMAIN) --build-arg MAX_SIZE=$(MAXSIZE) --build-arg MAX_SIZE=$(EXPIRE_TIME) --no-cache -t uguu:$(PKG_VERSION) . build-container: 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 mv uguuForDocker.tar.gz docker/ - docker build -f docker/Dockerfile --build-arg DOMAIN=$(SITEDOMAIN) --build-arg FILE_DOMAIN=$(FILESDOMAIN) --build-arg CONTACT_EMAIL=$(FILESDOMAIN) --build-arg MAX_SIZE=$(MAXSIZE) -t uguu:$(PKG_VERSION) . + docker build -f docker/Dockerfile --build-arg DOMAIN=$(SITEDOMAIN) --build-arg FILE_DOMAIN=$(FILESDOMAIN) --build-arg CONTACT_EMAIL=$(FILESDOMAIN) --build-arg MAX_SIZE=$(MAXSIZE) --build-arg MAX_SIZE=$(EXPIRE_TIME) -t uguu:$(PKG_VERSION) . run-container: docker run --name uguu -d -p 80:80 -p 443:443 uguu:$(PKG_VERSION) diff --git a/docker/Dockerfile b/docker/Dockerfile index 880e658..7678632 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -19,13 +19,19 @@ RUN apt-get install -y build-essential nginx-full php8.1-fpm php8.1 sqlite3 php8 # Set ENV values for configuration ARG DOMAIN ENV DOMAIN=$DOMAIN + ARG FILE_DOMAIN ENV FILE_DOMAIN=$FILE_DOMAIN + ARG CONTACT_EMAIL ENV CONTACT_EMAIL=$CONTACT_EMAIL + ARG MAX_SIZE ENV MAX_SIZE=$MAX_SIZE +ARG EXPIRE_TIME +ENV EXPIRE_TIME=$EXPIRE_TIME + # Set default workdir WORKDIR /var/www/ @@ -59,6 +65,10 @@ RUN chmod a+x /var/www/uguu/src/static/scripts/checkdb.sh && \ COPY docker/nginx/uguu.conf /etc/nginx/sites-enabled/uguu.conf COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf +# Modify expire time +RUN sed -i "s#XXX#${EXPIRE_TIME}#g" /var/www/uguu/src/static/scripts/checkfiles.sh +RUN sed -i "s#XXX#${EXPIRE_TIME}#g" /var/www/uguu/src/static/scripts/checkdb.sh + # Modify nginx values RUN sed -i "s#XMAINDOMAINX#${DOMAIN}#g" /etc/nginx/sites-enabled/uguu.conf RUN sed -i "s#XFILESDOMAINX#${FILE_DOMAIN}#g" /etc/nginx/sites-enabled/uguu.conf diff --git a/src/config.json b/src/config.json index 89a4763..da84c05 100755 --- a/src/config.json +++ b/src/config.json @@ -10,7 +10,7 @@ "tools.ejs" ], "max_upload_size": 128, - "expireTime": "48H", + "expireTime": "48", "siteName": "Uguu", "subTitle": "wahooo", "DOMAIN": "domain.com", diff --git a/src/static/scripts/checkdb.sh b/src/static/scripts/checkdb.sh index 7f6916f..e2d27a8 100644 --- a/src/static/scripts/checkdb.sh +++ b/src/static/scripts/checkdb.sh @@ -1 +1 @@ -sqlite3 /path/to/db/uguu.sq3 "DELETE FROM files WHERE date <= strftime('%s', datetime('now', '-1 day'));" \ No newline at end of file +sqlite3 /path/to/db/uguu.sq3 "DELETE FROM files WHERE date <= strftime('%s', datetime('now', '-XXX hours'));" \ No newline at end of file diff --git a/src/static/scripts/checkfiles.sh b/src/static/scripts/checkfiles.sh index 5c9e4bd..fff78b3 100644 --- a/src/static/scripts/checkfiles.sh +++ b/src/static/scripts/checkfiles.sh @@ -1,2 +1,3 @@ #! /bin/sh +hours=$((XXX*60)) find /path/to/files/ -mmin +1440 -exec rm -f {} \; \ No newline at end of file diff --git a/src/templates/partials/lead.ejs b/src/templates/partials/lead.ejs index 3dc236c..28ab933 100644 --- a/src/templates/partials/lead.ejs +++ b/src/templates/partials/lead.ejs @@ -1,6 +1,6 @@

<%= siteName %>~

- Max upload size is <%= max_upload_size %> MiB & files expire after <%= expireTime %>, read the + Max upload size is <%= max_upload_size %> MiB & files expire after <%= expireTime %>H, read the FAQ