From 8c676fd6e6b69e838131213f9b0f13c17f579853 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Thu, 16 Feb 2023 19:57:13 +0000 Subject: [PATCH] Add deployment script --- .conf/deploy.sh | 0 .conf/nginx.conf | 0 Dockerfile | 14 +++++++++++--- deploy/deploy.sh | 38 ++++++++++++++++++++++++++++++++++++++ deploy/nginx.conf | 38 ++++++++++++++++++++++++++++++++++++++ index.html | 25 ++----------------------- 6 files changed, 89 insertions(+), 26 deletions(-) delete mode 100644 .conf/deploy.sh delete mode 100644 .conf/nginx.conf create mode 100644 deploy/deploy.sh create mode 100644 deploy/nginx.conf diff --git a/.conf/deploy.sh b/.conf/deploy.sh deleted file mode 100644 index e69de29..0000000 diff --git a/.conf/nginx.conf b/.conf/nginx.conf deleted file mode 100644 index e69de29..0000000 diff --git a/Dockerfile b/Dockerfile index aa9d152..57aaddb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,12 @@ -FROM fedora:latest AS builder +FROM fedora:latest as compressor +RUN dnf install brotli nodejs npm jq -y +RUN npm i uglifyjs-folder uglifycss html-minifier-terser -g +COPY . /data/in +RUN bash /data/in/deploy/deploy.sh -FROM nginx:mainline-alpine-slim -COPY . /usr/share/nginx/html \ No newline at end of file +FROM fholzer/nginx-brotli:latest +RUN rm /etc/nginx/nginx.conf +RUN apk update +RUN apk add --upgrade libxml2 libxslt +COPY ./deploy/nginx.conf /etc/nginx/nginx.conf +COPY --from=compressor /data/out/ /site-static/ \ No newline at end of file diff --git a/deploy/deploy.sh b/deploy/deploy.sh new file mode 100644 index 0000000..1e5faac --- /dev/null +++ b/deploy/deploy.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +ROOTIN="/data/in" +ROOTOUT="/data/out" + +echo "Running UglifyJS on /data/in folder" +uglifyjs-folder "$ROOTIN" -x ".js" -eo "$ROOTOUT" + +echo "Running UglifyCSS" +CSSIN="/data/in/stylesheets/" +CSSOUT="/data/out/stylesheets" + +cd $CSSIN +echo "Changed directory" +for f in * +do + if [ -f "$f" ]; then + uglifycss "$f" --output "$f"; + fi +done + +echo "Moving 'styles' to 'out'" +cp -r $CSSIN $CSSOUT + +echo "Running html-minifier-terser on /folder" +HTMLIN="/data/in/" +HTMLOUT="/data/out" +html-minifier-terser --collapse-whitespace --remove-comments --file-ext html --input-dir /data/in/ --output-dir /data/out/ + +#echo "Moving JSON Manifest file from root to output" +#cat /data/in/manifest.json | jq -c > /data/out/manifest.json + +echo "Moving other files folder from in/ to out/" +cp -r /data/in/assets /data/out/assets +cp -r /data/in/fonts /data/out/fonts + +echo "Running GZIP & Brotli on all HTML, JS, CSS, JSON, SVG & TTF files" +find /data/out -type f -name \*.html -or -name \*.js -or -name \*.css -or -name \*.json -or -name \*.svg -or -name \*.ttf | while read file; do gzip -k -9 $file; brotli -k -q 11 $file; done \ No newline at end of file diff --git a/deploy/nginx.conf b/deploy/nginx.conf new file mode 100644 index 0000000..012f610 --- /dev/null +++ b/deploy/nginx.conf @@ -0,0 +1,38 @@ +user nginx; +worker_processes 1; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + + +events { + worker_connections 64; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + sendfile on; + keepalive_timeout 65; + + server { + listen 80; + server_name localhost; + + add_header Content-Security-Policy "default-src 'self'"; + + location / { + root /site-static/; + index index.html; + gzip_static on; + brotli_static on; + expires 3d; + add_header Cache-Control "public, no-transform"; + } + } +} \ No newline at end of file diff --git a/index.html b/index.html index 72c2114..f268fbd 100644 --- a/index.html +++ b/index.html @@ -1,30 +1,22 @@ - FJLA Gateway - - + - - -

FJLA Gateway

-

-
-
@@ -32,7 +24,6 @@

Personal Cloud

-
@@ -40,7 +31,6 @@

Smart Home

-
@@ -48,7 +38,6 @@

Video Streaming

-
@@ -56,12 +45,8 @@

Family Photos

-
- -
-
@@ -69,7 +54,6 @@

Your email

-
@@ -77,7 +61,6 @@

FreePBX UCP

-
@@ -85,7 +68,6 @@

Full list of services

-
@@ -93,7 +75,6 @@

Your Settings

-
@@ -101,8 +82,6 @@

Tell me more

-
- - + \ No newline at end of file