Skip to content

Commit 7a11454

Browse files
authored
Merge branch 'master' into newdesign
2 parents 4fc0932 + cb265a2 commit 7a11454

File tree

16 files changed

+339
-17
lines changed

16 files changed

+339
-17
lines changed

.eslintrc.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"worker": true
6+
},
7+
"extends": "eslint:recommended",
8+
"parserOptions": {
9+
"ecmaVersion": 2015,
10+
"sourceType": "script"
11+
},
12+
"globals": {
13+
"XMLHttpRequest": "readonly",
14+
"Worker": "readonly",
15+
"Blob": "readonly",
16+
"URL": "readonly",
17+
"navigator": "readonly",
18+
"document": "readonly",
19+
"window": "readonly",
20+
"console": "readonly",
21+
"setTimeout": "readonly",
22+
"clearTimeout": "readonly",
23+
"setInterval": "readonly",
24+
"clearInterval": "readonly",
25+
"postMessage": "readonly",
26+
"onmessage": "writable",
27+
"addEventListener": "readonly"
28+
},
29+
"rules": {
30+
"no-unused-vars": ["warn", { "args": "none" }],
31+
"no-console": "off",
32+
"no-empty": "warn",
33+
"no-undef": "warn",
34+
"no-const-assign": "error"
35+
}
36+
}

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"
12+
- package-ecosystem: "docker" # See documentation for possible values
13+
directory: "/" # Location of package manifests
14+
schedule:
15+
interval: "weekly"

.github/workflows/docker-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
steps:
4747
- name: Checkout repository
48-
uses: actions/checkout@v4
48+
uses: actions/checkout@v6
4949

5050
# Fetch the ipinfo database file using curl if API key is defined
5151
- name: Fetch DB from ipinfo.io
@@ -94,7 +94,7 @@ jobs:
9494
# https://github.com/docker/build-push-action
9595
- name: Build and push Docker image
9696
id: build-and-push
97-
uses: docker/build-push-action@v5
97+
uses: docker/build-push-action@v6
9898
with:
9999
context: .
100100
file: ${{ matrix.dockerfile }}

.github/workflows/stale.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
2+
#
3+
# You can adjust the behavior by modifying this file.
4+
# For more information, see:
5+
# https://github.com/actions/stale
6+
name: Mark stale issues and pull requests
7+
8+
on:
9+
schedule:
10+
- cron: '32 18 * * *'
11+
12+
jobs:
13+
stale:
14+
15+
runs-on: ubuntu-latest
16+
permissions:
17+
issues: write
18+
pull-requests: write
19+
20+
steps:
21+
- uses: actions/stale@v10
22+
with:
23+
repo-token: ${{ secrets.GITHUB_TOKEN }}
24+
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
25+
stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
26+
days-before-stale: 60
27+
days-before-close: 7
28+
close-issue-message: 'This issue was automatically closed due to inactivity.'
29+
close-pr-message: 'This pull request was automatically closed due to inactivity.'
30+
stale-issue-label: 'no-issue-activity'
31+
stale-pr-label: 'no-pr-activity'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ results/idObfuscation_salt.php
22
backend/getIP_serverLocation.php
33
db-dir/
44
.vscode/
5+
node_modules/
6+
package-lock.json

.prettierignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
node_modules/
2+
backend/
3+
results/
4+
docker/
5+
.git/
6+
*.php
7+
*.md
8+
*.sql
9+
*.mmdb
10+
*.phar
11+
*.ttf
12+
*.ico
13+
*.png
14+
*.gif

.prettierrc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": false,
7+
"trailingComma": "none",
8+
"bracketSpacing": true,
9+
"arrowParens": "avoid",
10+
"endOfLine": "lf",
11+
"htmlWhitespaceSensitivity": "ignore"
12+
}

DEVELOPMENT.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Development Guide
2+
3+
This document describes how to use the package manager (npm) for development tasks.
4+
5+
## Prerequisites
6+
7+
- Node.js 14.0.0 or higher
8+
- npm (comes with Node.js)
9+
10+
## Getting Started
11+
12+
Install development dependencies:
13+
14+
```bash
15+
npm install
16+
```
17+
18+
## Available Scripts
19+
20+
### Linting
21+
22+
Check code for potential issues:
23+
24+
```bash
25+
npm run lint
26+
```
27+
28+
Automatically fix linting issues where possible:
29+
30+
```bash
31+
npm run lint:fix
32+
```
33+
34+
### Code Formatting
35+
36+
Check code formatting (JavaScript files only):
37+
38+
```bash
39+
npm run format:check
40+
```
41+
42+
Format JavaScript files:
43+
44+
```bash
45+
npm run format
46+
```
47+
48+
> **Note**: The existing codebase uses its original formatting style. Prettier and ESLint are provided as optional tools for new code or improvements.
49+
50+
### Validation
51+
52+
Run all checks (formatting and linting):
53+
54+
```bash
55+
npm run validate
56+
```
57+
58+
### Testing
59+
60+
Currently, there are no automated tests configured:
61+
62+
```bash
63+
npm run test
64+
```
65+
66+
### Docker
67+
68+
Build Docker images:
69+
70+
```bash
71+
npm run docker:build # Standard Debian-based image
72+
npm run docker:build-alpine # Alpine-based image
73+
```
74+
75+
## Development Tools
76+
77+
The package manager setup includes:
78+
79+
- **ESLint**: JavaScript linting tool to catch common errors
80+
- **Prettier**: Code formatting tool to maintain consistent style
81+
82+
These tools are configured but non-intrusive to the existing codebase.
83+
84+
## Project Structure
85+
86+
```
87+
.
88+
├── speedtest.js # Main speedtest library
89+
├── speedtest_worker.js # Web Worker for speed testing
90+
├── index.html # Default UI
91+
├── backend/ # PHP backend files
92+
├── examples/ # Example implementations
93+
├── results/ # Results/telemetry handling
94+
├── docker/ # Docker-related files
95+
└── package.json # npm package configuration
96+
```
97+
98+
## Why Use a Package Manager?
99+
100+
The package manager provides several benefits:
101+
102+
1. **Standardized tooling**: Common commands across different environments
103+
2. **Development dependencies**: Easy installation of linting and formatting tools
104+
3. **Project metadata**: Version, description, and licensing information
105+
4. **Future extensibility**: Foundation for adding build tools, tests, or bundlers if needed
106+
5. **npm distribution**: Makes the library easy to use in other Node.js projects
107+
108+
## Contributing
109+
110+
When making changes:
111+
112+
1. Run `npm run lint` to check for potential issues
113+
2. Consider running `npm run format` on new files for consistency
114+
3. Test your changes manually in a browser
115+
4. For PHP backend changes, test with the appropriate server setup
116+
117+
## Notes
118+
119+
- The core library has **no runtime dependencies** - it's pure vanilla JavaScript
120+
- Development dependencies (ESLint, Prettier) are only needed for development
121+
- The library can still be used standalone without npm (just include the JS files)
122+
- npm setup is completely optional and doesn't change how the library is deployed

Dockerfile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ FROM php:8-apache
33
# use docker-php-extension-installer for automatically get the right packages installed
44
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
55

6-
7-
# Install extensions
8-
RUN install-php-extensions iconv gd pdo pdo_mysql pdo_pgsql pgsql
9-
10-
RUN rm -f /usr/src/php.tar.xz /usr/src/php.tar.xz.asc \
11-
&& apt autoremove -y \
12-
&& rm -rf /var/lib/apt/lists/*
6+
# Install extensions and cleanup in a single layer to reduce image size
7+
RUN install-php-extensions iconv gd pdo pdo_mysql pdo_pgsql pgsql \
8+
&& rm -f /usr/src/php.tar.xz /usr/src/php.tar.xz.asc \
9+
&& apt-get autoremove -y \
10+
&& apt-get clean \
11+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
1312

1413
# Prepare files and folders
1514
RUN mkdir -p /speedtest/
@@ -41,6 +40,19 @@ ENV WEBPORT=8080
4140
# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
4241
STOPSIGNAL SIGWINCH
4342

43+
# Add labels for better metadata
44+
LABEL org.opencontainers.image.title="LibreSpeed"
45+
LABEL org.opencontainers.image.description="A Free and Open Source speed test that you can host on your server(s)"
46+
LABEL org.opencontainers.image.vendor="LibreSpeed"
47+
LABEL org.opencontainers.image.url="https://github.com/librespeed/speedtest"
48+
LABEL org.opencontainers.image.source="https://github.com/librespeed/speedtest"
49+
LABEL org.opencontainers.image.documentation="https://github.com/librespeed/speedtest/blob/master/doc_docker.md"
50+
LABEL org.opencontainers.image.licenses="LGPL-3.0-or-later"
51+
52+
# Add health check
53+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
54+
CMD curl -f http://localhost:${WEBPORT}/ || exit 1
55+
4456
# Final touches
4557
EXPOSE ${WEBPORT}
4658
CMD ["bash", "/entrypoint.sh"]

Dockerfile.alpine

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@ RUN apk add --quiet --no-cache \
1515
php-session \
1616
php-sqlite3
1717

18-
# use docker-php-extension-installer for automatically get the right packages installed
19-
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
20-
21-
22-
# Install extensions
23-
RUN install-php-extensions iconv gd pdo pdo_mysql pdo_pgsql pgsql
18+
# Note: PHP extensions are provided via Alpine `php-*` packages above.
19+
# The docker-php-extension-installer is redundant when using those packages,
20+
# so it's intentionally removed to simplify the image.
2421

2522
RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
2623
ln -sf /dev/stderr /var/log/apache2/error.log
@@ -55,6 +52,19 @@ ENV WEBPORT=8080
5552
# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
5653
STOPSIGNAL SIGWINCH
5754

55+
# Add labels for better metadata
56+
LABEL org.opencontainers.image.title="LibreSpeed"
57+
LABEL org.opencontainers.image.description="A Free and Open Source speed test that you can host on your server(s)"
58+
LABEL org.opencontainers.image.vendor="LibreSpeed"
59+
LABEL org.opencontainers.image.url="https://github.com/librespeed/speedtest"
60+
LABEL org.opencontainers.image.source="https://github.com/librespeed/speedtest"
61+
LABEL org.opencontainers.image.documentation="https://github.com/librespeed/speedtest/blob/master/doc_docker.md"
62+
LABEL org.opencontainers.image.licenses="LGPL-3.0-or-later"
63+
64+
# Add health check
65+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
66+
CMD wget --no-verbose --tries=1 --spider http://localhost:${WEBPORT}/ || exit 1
67+
5868
WORKDIR /var/www/html
5969

6070
# Final touches

0 commit comments

Comments
 (0)