mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-25 06:49:15 +01:00
Added all files to build image from
This commit is contained in:
40
Dockerfile
Normal file
40
Dockerfile
Normal file
@@ -0,0 +1,40 @@
|
||||
FROM webdevops/php-nginx:ubuntu-18.04
|
||||
MAINTAINER henrywhitaker3@outlook.com
|
||||
|
||||
ENV WEB_DOCUMENT_ROOT /app/site/public
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install apt stuff
|
||||
RUN apt-get update
|
||||
RUN apt-get install \
|
||||
python3 \
|
||||
python3-pip -y
|
||||
|
||||
# Install speedtest-cli
|
||||
RUN pip3 install speedtest-cli
|
||||
|
||||
# Copy over static files
|
||||
RUN mkdir /setup
|
||||
COPY conf/ /setup/
|
||||
|
||||
# Copy over Speedtest site files
|
||||
RUN cp -r /setup/site/ /app/
|
||||
|
||||
# Setup env file
|
||||
RUN cd /app/site \
|
||||
&& cp .env.example .env \
|
||||
&& sed 's/DB_DATABASE=.*/DB_DATABASE=\/config\/speed.db/' -i.bak .env
|
||||
|
||||
# Copy supervisor queue worker config
|
||||
RUN cp /setup/laravel-worker.conf /opt/docker/etc/supervisor.d/
|
||||
|
||||
# Set permissions for files
|
||||
RUN cp /setup/entrypoint/init.sh /entrypoint.d
|
||||
RUN chmod +x /setup/entrypoint/init.sh
|
||||
RUN chown -R application:application /app
|
||||
RUN chmod -R 775 /app
|
||||
|
||||
# Cleanup setup files
|
||||
RUN rm -r /setup
|
||||
|
||||
VOLUME ["/config"]
|
||||
45
README.md
Normal file
45
README.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# Speedtest Tracker
|
||||
|
||||
This program runs a speedtest check every hour and graphs the results. The back-end is written in [Laravel](https://laravel.com/) and the front-end uses [React](https://reactjs.org/). It uses the [speedtest-cli](https://github.com/sivel/speedtest-cli) package to get the data and uses [Chart.js](https://www.chartjs.org/) to plot the results.
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
|
||||
- Automatically run a speedtest every hour
|
||||
- Graph of previous speedtests going back x days
|
||||
- Backup/restore data in JSON format
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
docker create \
|
||||
--name=speedtest \
|
||||
-p 8765:80 \
|
||||
-v /path/to/data:/config \
|
||||
--restart unless-stopped \
|
||||
henrywhitaker3/speedtest-tracker
|
||||
```
|
||||
|
||||
## Getting the Image
|
||||
|
||||
To get the base image, you have 2 options:
|
||||
|
||||
- Use the pre-built image on dockerhub
|
||||
- Build the image yourself
|
||||
|
||||
### Pre-built Image
|
||||
|
||||
Run `docker pull henrywhitaker3/speedtest-tracker`
|
||||
|
||||
### Dockerfile
|
||||
|
||||
Clone the required files from the github repo [here](https://github.com/henrywhitaker3/Speedtest-Tracker/tree/docker) maing sure to use the `docker` branch of the repo.
|
||||
|
||||
Build the image form the docker file by running (within the cloned git repo):
|
||||
|
||||
```bash
|
||||
docker build . -f Dockerfile --tag=henrywhitaker3/speedtest-tracker:<tag>
|
||||
```
|
||||
|
||||
|
||||
25
conf/entrypoint/init.sh
Normal file
25
conf/entrypoint/init.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
# This script sets up the
|
||||
|
||||
if [ ! -f /config/speed.db ]; then
|
||||
echo "Database file not found!"
|
||||
echo "Creating the database..."
|
||||
touch /config/speed.db
|
||||
fi
|
||||
|
||||
if cat /app/site/.env | grep -E "APP_KEY=base64" > /dev/null; then
|
||||
echo "App key found. Skipping app key generation"
|
||||
else
|
||||
echo "No app key found. Generating app key"
|
||||
cd /app/site && php artisan key:generate
|
||||
fi
|
||||
|
||||
cd /app/site && php artisan migrate
|
||||
|
||||
cd /config
|
||||
mkdir -p logs
|
||||
|
||||
chown -R application /config
|
||||
chmod 775 -R /config
|
||||
|
||||
echo "* * * * * cd /app/site/ && php artisan schedule:run >> /dev/null 2>&1" | crontab -
|
||||
9
conf/laravel-worker.conf
Normal file
9
conf/laravel-worker.conf
Normal file
@@ -0,0 +1,9 @@
|
||||
[program:laravel-worker]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=php /app/site/artisan queue:work
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=application
|
||||
numprocs=1
|
||||
redirect_stderr=true
|
||||
logfile=/config/logs/laravel-worker.log
|
||||
Reference in New Issue
Block a user