README update
This commit is contained in:
39
README.md
39
README.md
@@ -6,44 +6,63 @@ Debian-based Docker image that runs hourly network speed tests (using speedtest-
|
|||||||
|
|
||||||
Docker[^1] image on [Docker Hub](https://hub.docker.com/repository/docker/asolkar/speed-data-docker/general)
|
Docker[^1] image on [Docker Hub](https://hub.docker.com/repository/docker/asolkar/speed-data-docker/general)
|
||||||
|
|
||||||
## What the container provides
|
### What the container provides
|
||||||
- Base: debian
|
- Base: debian
|
||||||
- Installs: speedtest-cli
|
- Installs: speedtest-cli
|
||||||
- Runs: a cron job to execute `run_speed_test.sh` hourly
|
- Runs: a cron job to execute `run_speed_test.sh` hourly
|
||||||
- Serves: `index.html` and generated JS files on port 8080 via busybox httpd
|
- Serves: `index.html` and generated JS files on port 8080 via busybox httpd
|
||||||
|
|
||||||
## Files added/edited
|
### Files added/edited
|
||||||
- `Dockerfile` - builds the image
|
- `Dockerfile` - builds the image
|
||||||
- `start.sh` - entrypoint: starts cron and httpd
|
- `start.sh` - entrypoint: starts cron and httpd
|
||||||
- `run_speed_test.sh` - existing script (copied into image)
|
- `run_speed_test.sh` - existing script (copied into image)
|
||||||
|
|
||||||
## Build locally
|
### Build locally
|
||||||
Make sure Docker is installed locally. From the project root run:
|
Make sure Docker is installed locally. From the project root run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build -t speed-data-app .
|
docker build -t speed-data-app .
|
||||||
```
|
```
|
||||||
|
|
||||||
## Run container
|
### Prepare for Docker Hub
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker image build --no-cache -t asolkar/speed-data-docker:_VERSION_ .
|
||||||
|
docker push asolkar/speed-data-docker:_VERSION_
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run container
|
||||||
|
|
||||||
|
Run with a named Docker volume (recommended). The container serves on `$PORT`
|
||||||
|
inside the container (default 8080). Map a host port to the container port with
|
||||||
|
`-p <host_port>:<container_port>`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Run with a named Docker volume (recommended). The container serves on $PORT inside the container
|
|
||||||
# (default 8080). Map a host port to the container port with -p <host_port>:<container_port>.
|
|
||||||
docker volume create speed-data-volume
|
docker volume create speed-data-volume
|
||||||
docker run -d --name speed-data -e PORT=8080 -p 8080:8080 --restart unless-stopped \
|
docker run -d --name speed-data -e PORT=8080 -p 8080:8080 --restart unless-stopped \
|
||||||
-v speed-data-volume:/var/www/data/speed \
|
-v speed-data-volume:/var/www/data/speed \
|
||||||
speed-data-app
|
speed-data-app
|
||||||
|
```
|
||||||
|
|
||||||
# Or run with a host bind mount (for direct access to files on the host):
|
Alternatively, run with a host bind mount (for direct access to files on the host):
|
||||||
docker run -d --name speed-data -e PORT=8080 -p 8080:8080 --restart unless-stopped \
|
|
||||||
-v /path/on/host/speed-data:/var/www/data/speed \
|
```bash
|
||||||
speed-data-app
|
docker rm -f speed-data || true \
|
||||||
|
&& docker volume create speed-data-volume && \
|
||||||
|
docker run -d --name speed-data -e CRON_MINUTE=18 -e PORT=8080 -p 8585:8080 --restart unless-stopped \
|
||||||
|
-v ~/docker-data/speed-data-app/data:/var/www/data/speed speed-data-app
|
||||||
```
|
```
|
||||||
|
|
||||||
## Verify
|
## Verify
|
||||||
- Visit http://localhost:8080 to view `index.html` (which reads `speedtest.js` and `speedtest.short.js`).
|
- Visit http://localhost:8080 to view `index.html` (which reads `speedtest.js` and `speedtest.short.js`).
|
||||||
- Cron runs at minute 0 every hour. Logs go to `/var/log/cron.log` inside the container.
|
- Cron runs at minute 0 every hour. Logs go to `/var/log/cron.log` inside the container.
|
||||||
|
|
||||||
|
## Log in to running container for debug
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec -it _CONTAINER_ID_ /bin/bash
|
||||||
|
```
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
- Data files (`speedtest.js`, `speedtest.short.js`, and the raw JSON file) are written to `/var/www/data/speed` inside the container. That path is declared as a Docker VOLUME in the `Dockerfile` so you can mount a named volume or a host directory.
|
- Data files (`speedtest.js`, `speedtest.short.js`, and the raw JSON file) are written to `/var/www/data/speed` inside the container. That path is declared as a Docker VOLUME in the `Dockerfile` so you can mount a named volume or a host directory.
|
||||||
- If you mount a host directory, ensure the directory is writeable by the container process. You can either:
|
- If you mount a host directory, ensure the directory is writeable by the container process. You can either:
|
||||||
|
|||||||
Reference in New Issue
Block a user