Refactor: New structure
This commit is contained in:
parent
f91da1f138
commit
a0cf1c4f8a
19 changed files with 266 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
/data.json
|
||||
/public
|
||||
/config
|
65
Dockerfile
Normal file
65
Dockerfile
Normal file
|
@ -0,0 +1,65 @@
|
|||
FROM alpine as builder
|
||||
|
||||
COPY . /src
|
||||
RUN apk add git && \
|
||||
echo "**** adding version ****" && \
|
||||
cd /src && \
|
||||
export VERSION=$(git describe --exact-match --tags $(git log -n1 --pretty='%h') || echo "dev - $(git rev-parse --short HEAD)") && \
|
||||
printf "<?php\n\$VERSION = \"$VERSION\";\n" > ./version.php
|
||||
|
||||
FROM ghcr.io/linuxserver/baseimage-alpine-nginx:2021.11.04
|
||||
|
||||
ARG gitcommithash
|
||||
LABEL maintainer="Dorian Zedler <mail@dorian.im>"
|
||||
|
||||
ENV MUSL_LOCPATH="/usr/share/i18n/locales/musl"
|
||||
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.13/community musl-locales musl-locales-lang \
|
||||
&& cd "$MUSL_LOCPATH" \
|
||||
&& for i in *.UTF-8; do \
|
||||
i1=${i%%.UTF-8}; \
|
||||
i2=${i1/_/-}; \
|
||||
i3=${i/_/-}; \
|
||||
cp -a "$i" "$i1"; \
|
||||
cp -a "$i" "$i2"; \
|
||||
cp -a "$i" "$i3"; \
|
||||
done
|
||||
|
||||
RUN \
|
||||
echo "**** install packages ****" && \
|
||||
apk update && \
|
||||
apk add --no-cache \
|
||||
curl \
|
||||
mysql-client \
|
||||
php7-ctype \
|
||||
php7-curl \
|
||||
php7-dom \
|
||||
php7-gd \
|
||||
php7-ldap \
|
||||
php7-mbstring \
|
||||
php7-memcached \
|
||||
php7-mysqlnd \
|
||||
php7-openssl \
|
||||
php7-pdo_mysql \
|
||||
php7-phar \
|
||||
php7-simplexml \
|
||||
php7-tokenizer \
|
||||
php7-intl \
|
||||
tar && \
|
||||
echo "**** configure php-fpm ****" && \
|
||||
sed -i 's/;clear_env = no/clear_env = no/g' /etc/php7/php-fpm.d/www.conf && \
|
||||
echo "catch_workers_output = yes" >> /etc/php7/php-fpm.d/www.conf && \
|
||||
echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php7/php-fpm.conf
|
||||
|
||||
RUN \
|
||||
echo "**** prepare root ****" && \
|
||||
rm -rf /var/www/html && \
|
||||
echo "**** cleanup ****" && \
|
||||
rm -rf \
|
||||
/tmp/*
|
||||
|
||||
COPY root/ /
|
||||
COPY src/ /var/www/html
|
||||
COPY --from=builder /src/version.php /var/www/html
|
||||
|
||||
VOLUME /config
|
||||
EXPOSE 80
|
11
docker-compose.yml
Normal file
11
docker-compose.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
version: "2"
|
||||
services:
|
||||
money-balancer:
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
volumes:
|
||||
- ./config:/config
|
||||
- ./src:/var/www/html
|
||||
ports:
|
||||
- 8888:80
|
30
root/etc/cont-init.d/20-config
Executable file
30
root/etc/cont-init.d/20-config
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# make our folders
|
||||
mkdir -p \
|
||||
/config/{www,log/nginx,keys,log/php} \
|
||||
/run \
|
||||
/var/lib/nginx/tmp/client_body \
|
||||
/var/tmp/nginx
|
||||
|
||||
#fix php-fpm log location
|
||||
sed -i "s#;error_log = log/php7/error.log.*#error_log = /config/log/php/error.log#g" /etc/php7/php-fpm.conf
|
||||
sed -i "s#;log_level = notice#log_level = debug#g" /etc/php7/php-fpm.conf
|
||||
|
||||
#fix php-fpm user
|
||||
sed -i "s#user = nobody.*#user = abc#g" /etc/php7/php-fpm.d/www.conf
|
||||
sed -i "s#group = nobody.*#group = abc#g" /etc/php7/php-fpm.d/www.conf
|
||||
|
||||
# backwards compatibility for alpine >=3.14
|
||||
if [ ! -e /etc/nginx/conf.d ]; then
|
||||
ln -s /etc/nginx/http.d /etc/nginx/conf.d
|
||||
fi
|
||||
|
||||
# permissions
|
||||
chown -R abc:abc \
|
||||
/config \
|
||||
/var/lib/nginx \
|
||||
/var/tmp/nginx
|
||||
chmod -R g+w \
|
||||
/config/{nginx,www}
|
||||
chmod -R 644 /etc/logrotate.d
|
11
root/etc/cont-init.d/50-config
Normal file
11
root/etc/cont-init.d/50-config
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
|
||||
chown -R abc:abc /var/www
|
||||
|
||||
# create directory structure
|
||||
mkdir -p \
|
||||
/config/www
|
||||
|
||||
# set permissions
|
||||
chown -R abc:abc \
|
||||
/config
|
28
root/etc/nginx/http.d/synced-timer.conf
Normal file
28
root/etc/nginx/http.d/synced-timer.conf
Normal file
|
@ -0,0 +1,28 @@
|
|||
server {
|
||||
listen 80 default_server;
|
||||
|
||||
listen 443 ssl;
|
||||
|
||||
root /var/www/html;
|
||||
|
||||
server_name _;
|
||||
|
||||
ssl_certificate /config/keys/cert.crt;
|
||||
ssl_certificate_key /config/keys/cert.key;
|
||||
|
||||
client_max_body_size 0;
|
||||
|
||||
location ^~ / {
|
||||
index index.php;
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
location ~* "\.php$" {
|
||||
# CHANGE TO YOUR NEEDS
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
try_files $fastcgi_script_name =404;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
}
|
||||
}
|
76
root/etc/nginx/nginx.conf
Normal file
76
root/etc/nginx/nginx.conf
Normal file
|
@ -0,0 +1,76 @@
|
|||
user abc;
|
||||
worker_processes 4;
|
||||
pid /run/nginx.pid;
|
||||
include /etc/nginx/modules/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
# multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
client_max_body_size 0;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /config/log/nginx/access.log;
|
||||
error_log /config/log/nginx/error.log;
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
gzip_disable "msie6";
|
||||
|
||||
# gzip_vary on;
|
||||
# gzip_proxied any;
|
||||
# gzip_comp_level 6;
|
||||
# gzip_buffers 16 8k;
|
||||
# gzip_http_version 1.1;
|
||||
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
##
|
||||
# nginx-naxsi config
|
||||
##
|
||||
# Uncomment it if you installed nginx-naxsi
|
||||
##
|
||||
|
||||
#include /etc/nginx/naxsi_core.rules;
|
||||
|
||||
##
|
||||
# nginx-passenger config
|
||||
##
|
||||
# Uncomment it if you installed nginx-passenger
|
||||
##
|
||||
|
||||
#passenger_root /usr;
|
||||
#passenger_ruby /usr/bin/ruby;
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
include /etc/nginx/http.d/*.conf;
|
||||
}
|
||||
|
||||
daemon off;
|
15
root/etc/services.d/nginx/run
Executable file
15
root/etc/services.d/nginx/run
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
|
||||
if pgrep -f "[n]ginx:" > /dev/null; then
|
||||
echo "Zombie nginx processes detected, sending SIGTERM"
|
||||
pkill -ef [n]ginx:
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
if pgrep -f "[n]ginx:" > /dev/null; then
|
||||
echo "Zombie nginx processes still active, sending SIGKILL"
|
||||
pkill -9 -ef [n]ginx:
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
exec /usr/sbin/nginx -c /etc/nginx/nginx.conf
|
2
root/etc/services.d/php-fpm/run
Normal file
2
root/etc/services.d/php-fpm/run
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
exec /usr/sbin/php-fpm7 -F
|
|
@ -16,7 +16,7 @@ class SyncedTimer
|
|||
private $_basepath;
|
||||
private $_resourcePath;
|
||||
private $_path;
|
||||
private $_dataFile = "./data.json";
|
||||
private $_dataFile = "/config/data/data.json";
|
||||
private $_storageHelper;
|
||||
|
||||
public function __construct($translations)
|
||||
|
@ -28,7 +28,7 @@ class SyncedTimer
|
|||
|
||||
$this->_calculateBasepath();
|
||||
$this->_themeConfig["basePath"] = $this->_basepath;
|
||||
$this->_themeConfig["mainIcon"] = $this->_resourcePath . "IconSmallSquareOutline.png";
|
||||
$this->_themeConfig["mainIcon"] = $this->_resourcePath . "static/img/IconSmallSquareOutline.png";
|
||||
$this->_theme = new LandingpageTheme($this->_themeConfig, $this->_storageHelper, $this->_translations);
|
||||
|
||||
$this->_processRequest();
|
||||
|
@ -121,7 +121,9 @@ class SyncedTimer
|
|||
"data" => array(
|
||||
"time" => $userdata["time"],
|
||||
"startedAt" => $userdata["startedAt"],
|
||||
"header" => $userdata["header"]
|
||||
"header" => $userdata["header"],
|
||||
"soundEnabled" => $userdata["soundEnabled"],
|
||||
"repeatEnabled" => $userdata["repeatEnabled"],
|
||||
)
|
||||
)));
|
||||
} else {
|
||||
|
@ -202,10 +204,14 @@ class SyncedTimer
|
|||
{
|
||||
$time = $_POST["time"];
|
||||
$header = $_POST["header"];
|
||||
$soundEnabled = $_POST["soundEnabled"] === "on";
|
||||
$repeatEnabled = $_POST["repeatEnabled"] === "on";
|
||||
$startedAt = time();
|
||||
$newData = array(
|
||||
"time" => intval($time),
|
||||
"header" => $header,
|
||||
"soundEnabled" => $soundEnabled,
|
||||
"repeatEnabled" => $repeatEnabled,
|
||||
"startedAt" => $startedAt
|
||||
);
|
||||
$this->_storageHelper->writeUserdata($_SESSION["auth"]["username"], $newData);
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
5
src/static/js/alpine.min.js
vendored
Normal file
5
src/static/js/alpine.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3
src/static/js/purify.min.js
vendored
Normal file
3
src/static/js/purify.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
src/static/sound/beep.mp3
Normal file
BIN
src/static/sound/beep.mp3
Normal file
Binary file not shown.
BIN
src/static/sound/countdown.mp3
Normal file
BIN
src/static/sound/countdown.mp3
Normal file
Binary file not shown.
|
@ -211,6 +211,14 @@ class LandingpageTheme
|
|||
<label for="time"><?= $this->_trId("time") ?></label>
|
||||
<input type="number" name="time" class="form-control" value="<?= $userData["time"] ?>" required>
|
||||
</div>
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" role="switch" name="soundEnabled" id="soundEnabledSwitch" <?= $userData["soundEnabled"] ? "checked":"" ?>>
|
||||
<label class="form-check-label" for="soundEnabledSwitch">Enable sound</label>
|
||||
</div>
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" role="switch" name="repeatEnabled" id="repeatEnabledSwitch" <?= $userData["repeatEnabled"] ? "checked":"" ?>>
|
||||
<label class="form-check-label" for="repeatEnabledSwitch">Repeat</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary"><?= $this->_trId("startTimer") ?></button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -275,7 +283,7 @@ class LandingpageTheme
|
|||
</main>
|
||||
|
||||
<footer class="mt-auto text-white-50">
|
||||
<p>Synced timer by <img height="40px" src="<?= $this->_globalConfig["basePath"] ?>/IconBig.png" /> <a href="https://www.itsblue.de" class="text-white">www.itsblue.de</a></p>
|
||||
<p>Synced timer by <img height="40px" src="<?= $this->_globalConfig["basePath"] ?>/static/img/IconBig.png" /> <a href="https://www.itsblue.de" class="text-white">www.itsblue.de</a></p>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
Loading…
Reference in a new issue