Skip to content

Commit

Permalink
Merge pull request #2 from librespeed/master
Browse files Browse the repository at this point in the history
update to 5.4.1
  • Loading branch information
cremesk authored Nov 11, 2024
2 parents 65a3c9e + ed9b19f commit 8afe939
Show file tree
Hide file tree
Showing 13 changed files with 222 additions and 131 deletions.
25 changes: 19 additions & 6 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ env:
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./Dockerfile
image: ghcr.io/${{ github.repository }}
flavour: ""
- dockerfile: ./Dockerfile.alpine
image: ghcr.io/${{ github.repository }}
flavour: "-alpine"
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -69,14 +79,16 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ matrix.image }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=branch,suffix=${{ matrix.flavour }}
type=ref,event=pr,suffix=${{ matrix.flavour }}
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest${{ matrix.flavour }},enable={{is_default_branch}}
type=semver,pattern={{version}}${{ matrix.flavour }}
type=semver,pattern={{major}}${{ matrix.flavour }}
type=semver,pattern={{major}}.{{minor}}${{ matrix.flavour }}
type=semver,pattern={{major}}.{{minor}}.{{patch}}${{ matrix.flavour }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
Expand All @@ -85,6 +97,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM php:8-apache

# Install extensions
RUN apt-get update && apt-get install -y \
RUN apt-get update && apt-get install -y --no-install-recommends \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
Expand All @@ -10,6 +10,12 @@ RUN apt-get update && apt-get install -y \
&& docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install -j$(nproc) gd pdo pdo_mysql pdo_pgsql pgsql \
&& rm -f /usr/src/php.tar.xz /usr/src/php.tar.xz.asc \
&& apt-get remove -y libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libpq-dev \
&& apt autoremove -y \
&& rm -rf /var/lib/apt/lists/*

# Prepare files and folders
Expand Down
59 changes: 59 additions & 0 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM php:8-alpine

# Install extensions
RUN apk add --quiet --no-cache \
bash \
apache2 \
apache2-ssl \
php83-apache2 \
php83-ctype \
php83-openssl \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libpq-dev \
&& docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install -j$(nproc) gd pdo pdo_mysql pdo_pgsql pgsql \
&& rm -f /usr/src/php.tar.xz /usr/src/php.tar.xz.asc \
&& apk del --quiet --no-cache \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libpq-dev

RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
ln -sf /dev/stderr /var/log/apache2/error.log

# Prepare files and folders
RUN mkdir -p /speedtest/

# Copy sources
COPY backend/ /speedtest/backend

COPY results/*.php /speedtest/results/
COPY results/*.ttf /speedtest/results/

COPY *.js /speedtest/
COPY favicon.ico /speedtest/

COPY docker/servers.json /servers.json

COPY docker/*.php /speedtest/
COPY docker/entrypoint.sh /

# Prepare default environment variables
ENV TITLE=LibreSpeed
ENV MODE=standalone
ENV PASSWORD=password
ENV TELEMETRY=false
ENV ENABLE_ID_OBFUSCATION=false
ENV REDACT_IP_ADDRESSES=false
ENV WEBPORT=80

# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
STOPSIGNAL SIGWINCH

# Final touches
EXPOSE 80
CMD ["bash", "/entrypoint.sh"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Works with mobile versions too.

* A reasonably fast web server with Apache 2 (nginx, IIS also supported)
* PHP 5.4 or newer (other backends also available)
* MySQL database to store test results (optional, Microsoft SQL Server, PostgreSQL and SQLite also supported)
* MariaDB or MySQL database to store test results (optional, Microsoft SQL Server, PostgreSQL and SQLite also supported)
* A fast! internet connection

## Installation
Expand Down
Binary file modified backend/country_asn.mmdb
Binary file not shown.
19 changes: 7 additions & 12 deletions backend/getIP.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function getIspInfo_ipinfoApi($ip){
require_once("geoip2.phar");
}
function getIspInfo_ipinfoOfflineDb($ip){
if (!file_exists(OFFLINE_IPINFO_DB_FILE) || !is_readable(OFFLINE_IPINFO_DB_FILE)){
if (PHP_MAJOR_VERSION < 8 || !file_exists(OFFLINE_IPINFO_DB_FILE) || !is_readable(OFFLINE_IPINFO_DB_FILE)){
return null;
}
$reader = new MaxMind\Db\Reader(OFFLINE_IPINFO_DB_FILE);
Expand Down Expand Up @@ -181,21 +181,16 @@ function formatResponse_simple($ip,$ispName=null){
if (is_string($localIpInfo)) {
echo formatResponse_simple($ip,$localIpInfo);
}else{
//ipinfo API and offline db require PHP 8 or newer
if (PHP_MAJOR_VERSION >= 8){
$r=getIspInfo_ipinfoApi($ip);
$r=getIspInfo_ipinfoApi($ip);
if(!is_null($r)){
echo $r;
}else{
$r=getIspInfo_ipinfoOfflineDb($ip);
if(!is_null($r)){
echo $r;
}else{
$r=getIspInfo_ipinfoOfflineDb($ip);
if(!is_null($r)){
echo $r;
}else{
echo formatResponse_simple($ip);
}
echo formatResponse_simple($ip);
}
}else{
echo formatResponse_simple($ip);
}
}
}else{
Expand Down
4 changes: 2 additions & 2 deletions doc.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# LibreSpeed

> by Federico Dossena
> Version 5.4
> Version 5.4.1
> [https://github.com/librespeed/speedtest/](https://github.com/librespeed/speedtest/)
## Introduction
Expand Down Expand Up @@ -77,7 +77,7 @@ To use this function, you will need a database. The test supports MySQL, Postgre

This step is only required for MySQL, PostgreSQL and MSSQL. If you want to use SQLite, skip to the next step.

Log into your database using phpMyAdmin or a similar software and create a new database. Inside the `results` folder you will find `telemetry_mysql.sql`, `telemetry_postgresql.sql` and `telemetry_mssql.sql`, which are templates for MySQL and PostgreSQL respectively. Import the one you need, and you will see a `speedtest_users` table in the database. You can delete the templates afterwards.
Log into your database using phpMyAdmin or a similar software and create a new database. Inside the `results` folder you will find `telemetry_mysql.sql`, `telemetry_postgresql.sql` and `telemetry_mssql.sql`, which are templates for MySQL, PostgreSQL and MSSQL respectively. Import the one you need, and you will see a `speedtest_users` table in the database. You can delete the templates afterwards.

##### Configuring telemetry

Expand Down
4 changes: 4 additions & 0 deletions doc_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

A docker version of LibreSpeed is available here: [GitHub Packages](https://github.com/librespeed/speedtest/pkgs/container/speedtest)

# Alpine Linux variant

An Alpine Linux based docker version of LibreSpeed is also available here: [GitHub Packages](https://github.com/librespeed/speedtest/pkgs/container/speedtest) under all the tags that have the `-alpine` suffix. This variant is significantly smaller but can have slightly different behaviour due to its toolchain being based in [musl](https://en.wikipedia.org/wiki/Musl) libc as mentioned in [here](https://alpinelinux.org/about/).

## Quickstart

If you just want to try it, the fastest way is:
Expand Down
19 changes: 16 additions & 3 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ cp /speedtest/*.js /var/www/html/
# Copy favicon
cp /speedtest/favicon.ico /var/www/html/

# Set custom webroot on alpine
if [ -f /etc/alpine-release ]; then
sed -i "s#\"/var/www/localhost/htdocs\"#\"/var/www/html\"#g" /etc/apache2/httpd.conf
fi

# Set up backend side for standlone modes
if [[ "$MODE" == "standalone" || "$MODE" == "dual" ]]; then
cp -r /speedtest/backend/ /var/www/html/backend
Expand Down Expand Up @@ -79,11 +84,19 @@ chown -R www-data /var/www/html/*

# Allow selection of Apache port for network_mode: host
if [ "$WEBPORT" != "80" ]; then
sed -i "s/^Listen 80\$/Listen $WEBPORT/g" /etc/apache2/ports.conf
sed -i "s/*:80>/*:$WEBPORT>/g" /etc/apache2/sites-available/000-default.conf
if [ -f /etc/alpine-release ]; then
sed -i "s/^Listen 80\$/Listen $WEBPORT/g" /etc/apache2/httpd.conf
else
sed -i "s/^Listen 80\$/Listen $WEBPORT/g" /etc/apache2/ports.conf
sed -i "s/*:80>/*:$WEBPORT>/g" /etc/apache2/sites-available/000-default.conf
fi
fi

echo "Done, Starting APACHE"

# This runs apache
exec apache2-foreground
if [ -f /etc/alpine-release ]; then
exec httpd -DFOREGROUND
else
exec apache2-foreground
fi
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@
html,body,#loading{
background:#202020;
color:#F4F4F4;
color-scheme:dark;
}
h1{
color:#E0E0E0;
Expand Down
2 changes: 1 addition & 1 deletion results/telemetry_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function getPdo($returnErrorMessage = false)
if($MsSql_WindowsAuthentication){
return new PDO($dsn, "", "", $pdoOptions);
} else {
return new PDO($dsn, $MySql_username, $MySql_password, $pdoOptions);
return new PDO($dsn, $MsSql_username, $MsSql_password, $pdoOptions);
}
}

Expand Down
Loading

0 comments on commit 8afe939

Please sign in to comment.