HUB
Sign inSign up
speedtest_app logo

alexdaiii/speedtest_app

By alexdaiii

•Updated about 4 years ago

Displays speedtest data

Image
0

250

alexdaiii/speedtest_app repository overview

⁠Speedtest App

This is a simple web app that runs the speedtest-cli package⁠ and displays the results in a simple web page.

The iperf tagged images does not include the runner for the speedtest. Another service that will run the speedtest and send data to this service to display the data.

This project uses SQLite to store the results. The docker compose file will create a volume, called <dirname>_sqlite - where <dirname> is the directory the project is located in, for the database directory located at /app/data.

⁠Installation

  1. Install Docker⁠ and Docker Compose⁠.
  2. Clone this repository and change into the directory you cloned it into.
version: "3.9"

volumes:
  sqlite: null

services:
  server:
    image: alexdaiii/speedtest_app:iperf
    volumes:
      - sqlite:/app/data
    ports:
      - "${APP_PORT:-8000}:8000"
    environment:
      TZ: "America/New_York"
  1. Run the app.
   docker compose up -d
  1. Open the app in your browser at http://localhost:8000

⁠Configuration

The app can be configured by editing the docker-compose.yml file and changing the environment variables.

version: "3.9"

volumes:
  sqlite: null

services:
  server:
    build:
      context: .
      dockerfile: Dockerfile
    image: alexdaiii/speedtest_app
    volumes:
      - sqlite:/app/data
    ports:
      - "${APP_PORT:-8000}:8000"
    environment:
      RUN_SPEEDTEST_INTERVAL: ${RUN_SPEEDTEST_INTERVAL:-6000}
      RUN_SPEEDTEST_ON_START: ${RUN_SPEEDTEST_ON_START:-true}

To add a new environment variable, add it to the environment section. Values in ${} are variables that can be set in a .env file (values can be hard coded as well). The value after the : is the default value if the variable is not set.

Available environment variables (tag iperf):

Environment variableDefault ValueDescription
PYTHON_ENVproductionUsed to set other variables automatically.
Valid values are 'dev', 'production' and 'test'
LOG_LEVEL20 if production, 10 otherwiseThe Python logging level
ENABLE_CORSfalseWhether to enable CORS
BACKEND_CORS_ORIGINS'["http://localhost:3000","localhost:3000",]'The origins to allow for CORS.
Takes in a list of origins
SERVE_FRONTENDTrueServe the frontend from theclient/out directory
DATABASE_DIRdataThe directory to store the database in
DB_FILEdata.dbThe name of the database file
SQLALCHEMY_ENGINE_ECHOTrue in dev, False otherwiseWhether to echo SQL queries to the console
SQLALCHEMY_DATABASE_URIsqlite+aiosqlite:///data/data.dbThe full URI to the database.
Should not be set manually
DEV_INIT_DBTrue in dev, False otherwiseWhether to initialize the database on startup
without using alembic
DEV_DROP_TABLES_ON_STARTTrue in dev, False otherwiseWhether to drop the database tables and recreate them
ACCESS_TOKEN_LIFETIME_SECONDS2592000The number of seconds the access token lives for. Default is 30 days

⁠Adding users

docker run --entrypoint "manage_app <ARGS>" alexdaiii/speedtest_app:iperf

Available args are:

{create_user,update_user} - positional arguments

if create_user is input:

positional arguments:
  username
  password

if update_user is input:

  --new-username NEW_USERNAME 
  --password PASSWORD 

⁠Manual Installation

This method is not recommended, but is provided for those who want to run the app without Docker.

  1. Install Python 3.10⁠.

  2. Install Node 18⁠.

  3. Install Yarn⁠.

  4. Clone this repository and change into the directory you cloned it into.

    git clone https://gitlab.com/alexdaiii/speedtest_app.git
    cd speedtest_app
    
  5. Create a virtual environment and install the Python dependencies.

    python -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    
  6. Run the database migrations. This will create a folder called data in the root directory of the project with a SQLite database file in it.

    make migration
    
  7. Change into the client directory and install the Node dependencies.

    yarn install
    
  8. Build the client. This will create a folder called out in the client directory.

    yarn build
    
  9. Change back into the root directory of the project and run the app.

    cd ..
    make run
    

Tag summary

Content type

Image

Digest

sha256:57bd19064…

Size

72.3 MB

Last updated

about 4 years ago

docker pull alexdaiii/speedtest_app:1.0.beta-iperf