Skip to content

Commit

Permalink
Version 0.1 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-treebeard authored Dec 31, 2020
1 parent 0902b79 commit c478749
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 67 deletions.
1 change: 0 additions & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
name: Publish to PYPI
on:
release:
types: [published]
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test-publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
name: Test Publish to PYPI
on: [pull_request]
jobs:
build-n-publish:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
name: Pytest
on:
pull_request:
push:
Expand All @@ -7,6 +6,7 @@ on:

jobs:
pytest:
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -34,6 +34,7 @@ jobs:
with:
python-version: ${{ matrix.cfg.python-version }}
- run: pip install poetry
- run: poetry -V
- run: poetry install
- uses: pre-commit/[email protected]
with:
Expand Down
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ repos:
name: sync setup.py with poetry
entry: |
bash -c ' \
if [[ $CI ]]; then
exit 0
fi
V=$(poetry version -s);
poetry build && tar -xvf dist/whaler-$V.tar.gz -C dist && diff dist/whaler-$V/setup.py setup.py \
|| cp dist/whaler-$V/setup.py setup.py \
Expand Down
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,71 @@
# whaler

A visual disk usage analyser for making docker images smaller
[![PyPI versions](https://img.shields.io/pypi/pyversions/whaler?logo=python&logoColor=white)](https://pypi.org/project/whaler)
[![PyPI versions](https://img.shields.io/pypi/v/whaler?logo=python&logoColor=white)](https://pypi.org/project/whaler)

**What?** A command-line tool for visually investigating the disk usage of docker images

**Why?** Large images are slow to move and expensive to store. They cost developer productivity by lengthening devops tasks and often contain unnecessary data

**Who is this for?** Primarily for engineers working with images containing Python packages.

## User Stories

This tool should allow you to answer questions such as:
1. Which file types are occupying the most disk space?
2. Which are my largest Python packages?
3. What are my unknown causes of high disk usage?

## Quick start

```bash
pip install whaler
```

### Run against a local directory
```
➜ whaler .venv
Running bash -c cd .venv && du -a -k
Done. Serving output at http://localhost:8000 (ctrl+c to exit)
Running python3 -m http.server 8000 --directory=_whaler/html
```

### Run against a docker image

The tool will pull the image first if it is not present.
```
whaler --image='hl:latest' /
Running docker run --rm --entrypoint=du --workdir=/ hl:latest -a -k
Ignoring what seems to be non-fatal error(s):
du: cannot access './proc/1/task/1/fd/4': No such file or directory
du: cannot access './proc/1/task/1/fdinfo/4': No such file or directory
du: cannot access './proc/1/fd/3': No such file or directory
du: cannot access './proc/1/fdinfo/3': No such file or directory


Done. Serving output at http://localhost:8000 (ctrl+c to exit)
Running python3 -m http.server 8000 --directory=_whaler/html
```

Done. Serving output at http://localhost:8000 (ctrl+c to exit)
Running python3 -m http.server 8000 --directory=_whaler/html

![HTML Report](docs/screen.png)


## Limitations

1. Platform: whaler uses `du` to gather disk usage data. It must be present in your docker image
2. Scale: I have tested the web UI with up to 500,000 file system nodes with `du` output of up to ~100MB.

## Alternatives/Complements to this tool:

1. Whaler can tell you what is taking up space in the final layer of your Docker image, but you may have intermediate layers which are contributing to the image size. For diving through the layers, use [dive](https://github.com/wagoodman/dive)
* **Related**: read up on [multi-stage builds](https://docs.docker.com/develop/develop-images/multistage-build/) to understand how to mitigate the problem of intermediate layers bloating your image.
1. For investigating disk usage in non-docker directories, [Disk Inventory X](http://www.derlien.com/) is a great tool on OS X which I have based whaler on.

## Developing

See `.github/workflows/test.yml` for the development platform and setup.

For UI, see [whaler-ui](https://github.com/treebeardtech/whaler-ui)
25 changes: 0 additions & 25 deletions docs/_config.yml

This file was deleted.

1 change: 0 additions & 1 deletion docs/_toc.yml

This file was deleted.

32 changes: 0 additions & 32 deletions docs/landing-page.ipynb

This file was deleted.

Binary file added docs/screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ packages = [
]
include = ["ui.zip"]
readme = "README.md"
version = "0.0.1"
version = "0.1"

[tool.poetry.scripts]
whaler = 'whaler.cli:run'
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
['whaler']

package_data = \
{'': ['*'], 'whaler': ['static/*']}
{'': ['*'], 'whaler': ['static/html.tgz']}

install_requires = \
['click>=7.1.2,<8.0.0',
Expand All @@ -21,9 +21,9 @@

setup_kwargs = {
'name': 'whaler',
'version': '0.0.1',
'version': '0.1',
'description': '',
'long_description': '# whaler\n\nA visual disk usage analyser for making docker images smaller\n',
'long_description': "# whaler\n\n[![PyPI versions](https://img.shields.io/pypi/pyversions/whaler?logo=python&logoColor=white)](https://pypi.org/project/whaler)\n[![PyPI versions](https://img.shields.io/pypi/v/whaler?logo=python&logoColor=white)](https://pypi.org/project/whaler)\n\n**What?** A command-line tool for visually investigating the disk usage of docker images\n\n**Why?** Large images are slow to move and expensive to store. They cost developer productivity by lengthening devops tasks and often contain unnecessary data\n\n**Who is this for?** Primarily for engineers working with images containing Python packages.\n\n## User Stories\n\nThis tool should allow you to answer questions such as:\n1. Which file types are occupying the most disk space?\n2. Which are my largest Python packages?\n3. What are my unknown causes of high disk usage?\n\n## Quick start\n\n```bash\npip install whaler\n```\n\n### Run against a local directory\n```\n➜ whaler .venv\nRunning bash -c cd .venv && du -a -k\nDone. Serving output at http://localhost:8000 (ctrl+c to exit)\nRunning python3 -m http.server 8000 --directory=_whaler/html\n```\n\n### Run against a docker image\n\nThe tool will pull the image first if it is not present.\n```\nwhaler --image='hl:latest' /\nRunning docker run --rm --entrypoint=du --workdir=/ hl:latest -a -k\nIgnoring what seems to be non-fatal error(s):\ndu: cannot access './proc/1/task/1/fd/4': No such file or directory\ndu: cannot access './proc/1/task/1/fdinfo/4': No such file or directory\ndu: cannot access './proc/1/fd/3': No such file or directory\ndu: cannot access './proc/1/fdinfo/3': No such file or directory\n\n\nDone. Serving output at http://localhost:8000 (ctrl+c to exit)\nRunning python3 -m http.server 8000 --directory=_whaler/html\n```\n\nDone. Serving output at http://localhost:8000 (ctrl+c to exit)\nRunning python3 -m http.server 8000 --directory=_whaler/html\n\n![HTML Report](docs/screen.png)\n\n\n## Limitations\n\n1. Platform: whaler uses `du` to gather disk usage data. It must be present in your docker image\n2. Scale: I have tested the web UI with up to 500,000 file system nodes with `du` output of up to ~100MB.\n\n## Alternatives/Complements to this tool:\n\n1. Whaler can tell you what is taking up space in the final layer of your Docker image, but you may have intermediate layers which are contributing to the image size. For diving through the layers, use [dive](https://github.com/wagoodman/dive)\n * **Related**: read up on [multi-stage builds](https://docs.docker.com/develop/develop-images/multistage-build/) to understand how to mitigate the problem of intermediate layers bloating your image.\n1. For investigating disk usage in non-docker directories, [Disk Inventory X](http://www.derlien.com/) is a great tool on OS X which I have based whaler on.\n\n## Developing\n\nSee `.github/workflows/test.yml` for the development platform and setup.\n\nFor UI, see [whaler-ui](https://github.com/treebeardtech/whaler-ui)",
'author': 'alex-treebeard',
'author_email': '[email protected]',
'maintainer': None,
Expand Down
2 changes: 1 addition & 1 deletion src/whaler/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
HTML_DIR = "html"
DU_FILENAME = "du.txt"
DU_ARGS = ("-a", "-k")
UI_FILENAME = "html.zip"
UI_FILENAME = "html.tgz"


@click.command()
Expand Down
Binary file added src/whaler/static/html.tgz
Binary file not shown.
Binary file removed src/whaler/static/html.zip
Binary file not shown.

0 comments on commit c478749

Please sign in to comment.