Skip to content

Commit eb5341a

Browse files
committed
initial commit
0 parents  commit eb5341a

File tree

115 files changed

+12677
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+12677
-0
lines changed

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/node_modules
2+
/public/build
3+
/public/hot
4+
/public/storage
5+
/storage/*.key
6+
/vendor
7+
.env
8+
.env.backup
9+
.phpunit.result.cache
10+
Homestead.json
11+
Homestead.yaml
12+
auth.json
13+
npm-debug.log
14+
yarn-error.log
15+
/.idea
16+
/.vscode

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

.env.docker

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
APP_NAME="Speedtest Tracker"
2+
APP_ENV=production
3+
APP_KEY=
4+
APP_DEBUG=false
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stderr
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
10+
11+
BROADCAST_DRIVER=log
12+
CACHE_DRIVER=file
13+
FILESYSTEM_DISK=local
14+
QUEUE_CONNECTION=database
15+
SESSION_DRIVER=file
16+
SESSION_LIFETIME=120
17+
18+
MEMCACHED_HOST=127.0.0.1
19+
20+
MAIL_MAILER=smtp
21+
MAIL_HOST=mailhog
22+
MAIL_PORT=1025
23+
MAIL_USERNAME=null
24+
MAIL_PASSWORD=null
25+
MAIL_ENCRYPTION=null
26+
MAIL_FROM_ADDRESS="[email protected]"
27+
MAIL_FROM_NAME="${APP_NAME}"
28+
29+
AWS_ACCESS_KEY_ID=
30+
AWS_SECRET_ACCESS_KEY=
31+
AWS_DEFAULT_REGION=us-east-1
32+
AWS_BUCKET=
33+
AWS_USE_PATH_STYLE_ENDPOINT=false
34+
35+
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
36+
VITE_PUSHER_HOST="${PUSHER_HOST}"
37+
VITE_PUSHER_PORT="${PUSHER_PORT}"
38+
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
39+
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.env.example

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
APP_NAME="Speedtest Tracker"
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
10+
11+
DB_CONNECTION=mysql
12+
DB_HOST=127.0.0.1
13+
DB_PORT=3306
14+
DB_DATABASE=speedtest_tracker
15+
DB_USERNAME=root
16+
DB_PASSWORD=
17+
18+
BROADCAST_DRIVER=log
19+
CACHE_DRIVER=file
20+
FILESYSTEM_DISK=local
21+
QUEUE_CONNECTION=sync
22+
SESSION_DRIVER=file
23+
SESSION_LIFETIME=120
24+
25+
MEMCACHED_HOST=127.0.0.1
26+
27+
REDIS_HOST=127.0.0.1
28+
REDIS_PASSWORD=null
29+
REDIS_PORT=6379
30+
31+
MAIL_MAILER=smtp
32+
MAIL_HOST=mailhog
33+
MAIL_PORT=1025
34+
MAIL_USERNAME=null
35+
MAIL_PASSWORD=null
36+
MAIL_ENCRYPTION=null
37+
MAIL_FROM_ADDRESS="[email protected]"
38+
MAIL_FROM_NAME="${APP_NAME}"
39+
40+
AWS_ACCESS_KEY_ID=
41+
AWS_SECRET_ACCESS_KEY=
42+
AWS_DEFAULT_REGION=us-east-1
43+
AWS_BUCKET=
44+
AWS_USE_PATH_STYLE_ENDPOINT=false
45+
46+
PUSHER_APP_ID=
47+
PUSHER_APP_KEY=
48+
PUSHER_APP_SECRET=
49+
PUSHER_HOST=
50+
PUSHER_PORT=443
51+
PUSHER_SCHEME=https
52+
PUSHER_APP_CLUSTER=mt1
53+
54+
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
55+
VITE_PUSHER_HOST="${PUSHER_HOST}"
56+
VITE_PUSHER_PORT="${PUSHER_PORT}"
57+
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
58+
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
10+
CHANGELOG.md export-ignore
11+
.styleci.yml export-ignore

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/node_modules
2+
/public/build
3+
/public/hot
4+
/public/storage
5+
/storage/*.key
6+
/vendor
7+
.env
8+
.env.backup
9+
.phpunit.result.cache
10+
Homestead.json
11+
Homestead.yaml
12+
auth.json
13+
npm-debug.log
14+
yarn-error.log
15+
/.idea
16+
/.vscode

Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM serversideup/php:8.1-fpm-nginx
2+
3+
# Install addition packages
4+
RUN apt-get update && apt-get install -y \
5+
cron \
6+
supervisor \
7+
php8.1-bcmath \
8+
php8.1-pgsql \
9+
&& apt-get clean \
10+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \
11+
&& rm -f /etc/cont-init.d/50-laravel-automations
12+
13+
# Install Speedtest cli
14+
RUN curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | bash \
15+
&& apt-get install -y speedtest
16+
17+
# Copy package configs
18+
COPY docker/deploy/cron/scheduler /etc/cron.d/scheduler
19+
COPY docker/deploy/entrypoint /usr/local/bin/entrypoint
20+
COPY docker/deploy/etc/cont-init.d/ /etc/cont-init.d/
21+
COPY docker/deploy/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
22+
23+
RUN chmod 0644 /etc/cron.d/scheduler \
24+
&& crontab /etc/cron.d/scheduler \
25+
&& chmod +x /usr/local/bin/entrypoint
26+
27+
# Copy app
28+
COPY . /var/www/html
29+
COPY .env.docker .env
30+
31+
# Install app dependencies
32+
RUN composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev \
33+
&& chown -R 9999:9999 /var/www/html
34+
35+
ENTRYPOINT ["entrypoint"]

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
## Speedtest Tracker
2+
3+
Welcome to Speedtest Tracker! Speedtest Tracker runs a speedtest check against Ookla's Speedtest service on a schedule.
4+
5+
This project replaces https://github.com/henrywhitaker3/Speedtest-Tracker as it looks like this project has been abandoned https://github.com/henrywhitaker3/Speedtest-Tracker/issues/1013.
6+
7+
### Roadmap
8+
To suggest features please use the roadmap. You can also follow development progress there as well: https://speedtest-tracker-roadmap.alexjustesen.dev/
9+
10+
11+
### Deployment
12+
13+
#### Docker w/ sqlite
14+
```bash
15+
docker run -itd --name speedtest-tracker \
16+
-p 8080:80 \
17+
-e "PHP_POOL_NAME=speedtest-tracker_php" \
18+
-e "DB_CONNECTION=sqlite" \
19+
-e "DB_DATABASE=/appdata/database.sqlite" \
20+
-v speedtest-tracker_app:/appdata \
21+
speedtest-tracker
22+
```
23+
24+
#### Docker w/ MariaDB or MySQL
25+
```bash
26+
docker run -itd --name speedtest-tracker \
27+
-p 8080:80 \
28+
-e "PHP_POOL_NAME=speedtest-tracker_php" \
29+
-e "DB_CONNECTION=mysql" \
30+
-e "DB_HOST=mysql" \
31+
-e "DB_PORT=3306" \
32+
-e "DB_DATABASE=speedtest_tracker" \
33+
-e "DB_USERNAME=" \
34+
-e "DB_PASSWORD=" \
35+
speedtest-tracker
36+
```
37+
38+
#### Docker Compose
39+
```bash
40+
# tbd...
41+
```
42+
43+
44+
### Build Docker Image
45+
Want to build the image locally? Cool, just clone the repo and go right ahead...
46+
47+
```bash
48+
docker build . -t speedtest-tracker
49+
```
50+
51+
#### Runing the docker image
52+
```bash
53+
docker run -it -p 8080:80 \
54+
speedtest-tracker
55+
```
56+
57+
### Development
58+
59+
Since this project uses Laravel as our framework of choice we can take advantage of [Laravel Sail](https://laravel.com/docs/9.x/sail) for a development environment.
60+
61+
#### Clone the repo
62+
63+
```bash
64+
gh repo clone alexjustesen/speedtest-tracker \
65+
&& cd speedtest-tracker \
66+
&& cp .env.example .env
67+
```
68+
69+
#### Install composer dependencies
70+
```bash
71+
docker run --rm \
72+
-u "$(id -u):$(id -g)" \
73+
-v $(pwd):/var/www/html \
74+
-w /var/www/html \
75+
laravelsail/php81-composer:latest \
76+
composer install --ignore-platform-reqs
77+
```
78+
79+
#### Start sail
80+
```bash
81+
./vendor/bin/sail up -d
82+
83+
# or, if you have the sail bash alias
84+
sail up -d
85+
```
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Support\Facades\Artisan;
7+
use Illuminate\Support\Facades\Log;
8+
use Illuminate\Support\Facades\Storage;
9+
use Symfony\Component\Process\Process;
10+
11+
class AppStartupCommand extends Command
12+
{
13+
/**
14+
* The name and signature of the console command.
15+
*
16+
* @var string
17+
*/
18+
protected $signature = 'app:startup';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'Runs when the app is started to make sure everything is ok';
26+
27+
/**
28+
* Execute the console command.
29+
*
30+
* @return int
31+
*/
32+
public function handle()
33+
{
34+
$this->info('🐇 Starting up Speedtest Tracker...');
35+
$this->newLine();
36+
37+
$this->clearAppCache();
38+
39+
// $this->checkAppKey();
40+
41+
// $this->checkAppDatabase();
42+
43+
// $this->migrateDatabase();
44+
45+
$this->line('🚀 Speedtest Tracker is ready to roll!');
46+
47+
return 0;
48+
}
49+
50+
private function checkAppDatabase()
51+
{
52+
if (! Storage::exists('database.sqlite')) {
53+
$this->line('🙄 Database not found, creating a new one...');
54+
55+
$process = new Process(['touch', 'storage/app/database.sqlite']);
56+
$process->run();
57+
58+
if (! Storage::exists('database.sqlite')) {
59+
$this->error('❌ There was an issue creating the database, check the logs');
60+
}
61+
62+
$this->line('✅ done');
63+
$this->newLine();
64+
}
65+
}
66+
67+
private function checkAppKey()
68+
{
69+
if (blank(config('app.key'))) {
70+
$this->line('🔑 Generating a key...');
71+
72+
Artisan::call('key:generate');
73+
74+
$this->line('✅ done');
75+
$this->newLine();
76+
}
77+
}
78+
79+
private function clearAppCache()
80+
{
81+
$this->line('💵 Clearing the cache...');
82+
83+
Artisan::call('optimize');
84+
85+
$this->line('✅ done');
86+
$this->newLine();
87+
}
88+
89+
private function migrateDatabase()
90+
{
91+
$this->line('⏳ Migrating the database...');
92+
93+
try {
94+
Artisan::call('migrate', [
95+
'--database' => 'sqlite',
96+
'--force' => true,
97+
]);
98+
} catch (\Throwable $th) {
99+
$this->error('❌ There was an issue migrating the database, check the logs');
100+
101+
Log::info($th);
102+
}
103+
104+
$this->line('✅ done');
105+
$this->newLine();
106+
}
107+
}

0 commit comments

Comments
 (0)