Changed dockerfile

Added changes from 1489a8f8a4
This commit is contained in:
Henry Whitaker
2020-06-18 18:06:11 +01:00
parent e767d8a0e7
commit c545613d79
8 changed files with 156 additions and 40 deletions

View File

@@ -1,7 +1,6 @@
FROM linuxserver/nginx
MAINTAINER henrywhitaker3@outlook.com
FROM lsiobase/alpine:3.12 as build-stage
# Install apt stuff
# Install apk stuff
RUN apk add --no-cache --upgrade \
gcc \
cmake \
@@ -9,29 +8,26 @@ RUN apk add --no-cache --upgrade \
libxml2-dev \
build-base \
openssl-dev \
supervisor
# Copy over static files
COPY conf/ /setup/
# Get and compile SpeedTest++
RUN cd /tmp && \
git && \
cd /tmp && \
git clone https://github.com/taganaka/SpeedTest && \
cd SpeedTest && \
cmake -DCMAKE_BUILD_TYPE=Release . && \
cd /tmp/SpeedTest && \
make install && \
mv /usr/local/bin/SpeedTest /setup/site/app/Bin/
make install
# Setup new init script
RUN cp /setup/entrypoint/init.sh /etc/cont-init.d/50-speedtest
FROM linuxserver/nginx
MAINTAINER henrywhitaker3@outlook.com
# Update webroot
RUN cp /setup/default /defaults/default
# Install apt stuff
# RUN apk add --no-cache --upgrade supervisor
RUN mkdir -p /etc/services.d/supervisord/ && \
cp /setup/supervisor-service.sh /etc/services.d/supervisord/run && \
mkdir -p /etc/supervisor.d/ && \
cp /setup/laravel-worker.conf /etc/supervisor.d/laravel-worker.ini
# Copy over static files
COPY conf/ /
# Get SpeedTest++
COPY --from=build-stage /usr/local/bin/SpeedTest /site/app/Bin/
EXPOSE 80 443
VOLUME ["/config"]

9
conf/defaults/crontab Normal file
View File

@@ -0,0 +1,9 @@
# do daily/weekly/monthly maintenance
# min hour day month weekday command
*/15 * * * * run-parts /etc/periodic/15min
0 * * * * run-parts /etc/periodic/hourly
0 2 * * * run-parts /etc/periodic/daily
0 3 * * 6 run-parts /etc/periodic/weekly
0 5 1 * * run-parts /etc/periodic/monthly
# speedtest cron
* * * * * php /config/www/artisan schedule:run >> /config/log/speedtest/cron.log

View File

@@ -3,10 +3,7 @@
# Copy site files to /config
echo "Copying latest site files to config"
cp -rfT /setup/site/ /config/www/
chown -R abc:abc /config/www
chmod -R 755 /config/www/storage
chmod -R 755 /config/www/bootstrap
cp -rfT /site/ /config/www/
# Check for DB
if [ ! -f /config/speed.db ]; then
@@ -21,7 +18,7 @@ fi
# Check for .env
if [ ! -f /config/www/.env ]; then
echo "Env file not found! Creating .env file"
cp /setup/site/.env.example /config/www/.env
cp /site/.env.example /config/www/.env
else
echo "Env file exists"
fi
@@ -32,7 +29,7 @@ echo "Running database migrations"
php /config/www/artisan migrate
# Check app key exists
if cat /config/www/.env | grep -E "APP_KEY=[0-9A-Za-z:+\/=]{1,}" > /dev/null ; then
if grep -E "APP_KEY=[0-9A-Za-z:+\/=]{1,}" /config/www/.env > /dev/null; then
echo "App key exists"
else
echo "Generating app key"
@@ -40,7 +37,7 @@ else
fi
# Check JWT secret exists
if cat /config/www/.env | grep -E "JWT_SECRET=[0-9A-Za-z:+\/=]{1,}" > /dev/null ; then
if grep -E "JWT_SECRET=[0-9A-Za-z:+\/=]{1,}" /config/www/.env > /dev/null ; then
echo "JWT secret exists"
else
echo "Generating JWT secret"
@@ -64,4 +61,7 @@ else
fi
mkdir -p /config/log/speedtest
echo "* * * * * php /config/www/artisan schedule:run >> /config/log/speedtest/cron.log" >> /etc/crontabs/root
cp /defaults/crontab /etc/crontabs/root
chown -R abc:abc /config

View File

@@ -0,0 +1,3 @@
#!/usr/bin/with-contenv bash
exec s6-setuidgid abc php /config/www/artisan queue:work --timeout=120 >> /config/log/speedtest/queue.log

View File

@@ -1,9 +0,0 @@
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /config/www/artisan queue:work --timeout=120
autostart=true
autorestart=true
user=abc
numprocs=1
redirect_stderr=true
logfile=/config/log/speedtest/laravel-worker.log

View File

@@ -0,0 +1,120 @@
//
// Created by Francesco Laurita on 6/2/16.
//
#ifndef SPEEDTEST_TESTCONFIGTEMPLATE_H
#define SPEEDTEST_TESTCONFIGTEMPLATE_H
#include "SpeedTest.h"
const TestConfig preflightConfigDownload = {
600000, // start_size
2000000, // max_size
125000, // inc_size
4096, // buff_size
10000, // min_test_time_ms
1, // Concurrency
"Preflight check"
};
const TestConfig slowConfigDownload = {
100000, // start_size
500000, // max_size
10000, // inc_size
1024, // buff_size
20000, // min_test_time_ms
1, // Concurrency
"Very-slow-line line type detected: profile selected slowband"
};
const TestConfig slowConfigUpload = {
50000, // start_size
80000, // max_size
1000, // inc_size
1024, // buff_size
20000, // min_test_time_ms
1, // Concurrency
"Very-slow-line line type detected: profile selected slowband"
};
const TestConfig narrowConfigDownload = {
1000000, // start_size
100000000, // max_size
750000, // inc_size
4096, // buff_size
20000, // min_test_time_ms
1, // Concurrency
"Buffering-lover line type detected: profile selected narrowband"
};
const TestConfig narrowConfigUpload = {
1000000, // start_size
100000000, // max_size
550000, // inc_size
4096, // buff_size
20000, // min_test_time_ms
1, // Concurrency
"Buffering-lover line type detected: profile selected narrowband"
};
const TestConfig broadbandConfigDownload = {
1000000, // start_size
100000000, // max_size
750000, // inc_size
65536, // buff_size
20000, // min_test_time_ms
1, // concurrency
"Broadband line type detected: profile selected broadband"
};
const TestConfig broadbandConfigUpload = {
1000000, // start_size
70000000, // max_size
250000, // inc_size
65536, // buff_size
20000, // min_test_time_ms
1, // concurrency
"Broadband line type detected: profile selected broadband"
};
const TestConfig fiberConfigDownload = {
5000000, // start_size
120000000, // max_size
950000, // inc_size
65536, // buff_size
20000, // min_test_time_ms
1, // concurrency
"Fiber / Lan line type detected: profile selected fiber"
};
const TestConfig fiberConfigUpload = {
1000000, // start_size
70000000, // max_size
250000, // inc_size
65536, // buff_size
20000, // min_test_time_ms
1, // concurrency
"Fiber / Lan line type detected: profile selected fiber"
};
void testConfigSelector(const double preSpeed, TestConfig& uploadConfig, TestConfig& downloadConfig){
uploadConfig = slowConfigUpload;
downloadConfig = slowConfigDownload;
if (preSpeed > 4 && preSpeed <= 30){
downloadConfig = narrowConfigDownload;
uploadConfig = narrowConfigUpload;
} else if (preSpeed > 30 && preSpeed < 150) {
downloadConfig = broadbandConfigDownload;
uploadConfig = broadbandConfigUpload;
} else if (preSpeed >= 150) {
downloadConfig = fiberConfigDownload;
uploadConfig = fiberConfigUpload;
}
}
#endif //SPEEDTEST_TESTCONFIGTEMPLATE_H

View File

@@ -1,3 +0,0 @@
#!/usr/bin/with-contenv bash
exec supervisord --nodaemon --configuration /etc/supervisord.conf