Dockerize
This commit is contained in:
parent
59791b49ec
commit
3f66b8bf86
5
.dockerignore
Normal file
5
.dockerignore
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
nginx.Dockerfile
|
||||||
|
php.Dockerfile
|
||||||
|
.dockerignore
|
||||||
|
.gitignore
|
||||||
|
LICENSE
|
40
conf/deploy.sh
Normal file
40
conf/deploy.sh
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#!/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/styles/"
|
||||||
|
CSSOUT="/data/out/styles"
|
||||||
|
|
||||||
|
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/error-pages /data/out/error-pages
|
||||||
|
cp -r /data/in/page-blocks /data/out/page-blocks
|
||||||
|
cp -r /data/in/*.php /data/out
|
||||||
|
|
||||||
|
echo "Running GZIP & Brotli on all HTML, JS, CSS, JSON, SVG, TTF, VCF, PUB files"
|
||||||
|
find /data/out -type f -name \*.html -or -name \*.vcf -or -name \*.pub -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
|
57
conf/nginx.conf
Normal file
57
conf/nginx.conf
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
user nginx;
|
||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
error_log /var/log/nginx/error.log notice;
|
||||||
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 128;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
gzip_static on;
|
||||||
|
brotli_static on;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log;
|
||||||
|
root /site;
|
||||||
|
|
||||||
|
location ~ /(.git|php|page-blocks) {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
index index.php;
|
||||||
|
try_files $uri $uri/ $uri/index.php &uri/index.html =404;
|
||||||
|
break;
|
||||||
|
expires 7d;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
try_files $uri =404;
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
|
fastcgi_pass localhost:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_page 403 /error-pages/403.php;
|
||||||
|
error_page 404 /error-pages/404.php;
|
||||||
|
error_page 500 501 502 503 504 /error-pages/50x.php;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
12
nginx.Dockerfile
Normal file
12
nginx.Dockerfile
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
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/conf/deploy.sh
|
||||||
|
|
||||||
|
FROM fholzer/nginx-brotli:latest
|
||||||
|
RUN rm /etc/nginx/nginx.conf
|
||||||
|
RUN apk update
|
||||||
|
RUN apk add --upgrade libxml2 libxslt
|
||||||
|
COPY ./conf/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
COPY --from=compressor /data/out/ /site/
|
3
php.Dockerfile
Normal file
3
php.Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
FROM php:8.2.1-fpm-alpine
|
||||||
|
|
||||||
|
COPY . /site
|
Reference in New Issue
Block a user