• Stars
    star
    113
  • Rank 300,141 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🐳 Keep an eye on your docker image size and prevent it from growing too big

docker-image-size-limit

wemake.services Build status codecov Python Version wemake-python-styleguide

Limit your docker image size with a simple CLI command. Perfect to be used inside your CI process.

Read the announcing post.

Installation

pip install docker-image-size-limit

Or use our Github Action or pre-built docker image.

Usage

We support just a single command:

$ disl your-image-name:label 300MiB
your-image-name:label exceeds 300MiB limit by 114.4 MiB

Options

You can specify your image as:

  • Image name: python
  • Image name with tag: python:3.6.6-alpine

You can specify your size as:

  • Raw number of bytes: 1024
  • Human-readable megabytes: 30 MB or 30 MiB
  • Human-readable gigabytes: 1 GB or 1 GiB
  • Any other size supported by humanfriendly

Programmatic usage

You can also import and use this library as python code:

from docker import from_env
from docker_image_size_limit import check_image_size

oversize = check_image_size(from_env(), 'image-name:latest', '1 GiB')
assert oversize < 0, 'Too big image!'  # negative oversize - is a good thing!

We also ship PEP-561 compatible type annotations with this library.

Github Action

You can also use this check as a Gihub Action:

- uses: wemake-services/docker-image-size-limit@master
  with:
    image: "$YOUR_IMAGE_NAME"
    size: "$YOUR_SIZE_LIMIT"

Here's an example.

Docker Image

We have a pre-built image available.

First, pull our pre-built docker image:

docker pull wemakeservices/docker-image-size-limit

Then you can use it like so:

docker run -v /var/run/docker.sock:/var/run/docker.sock --rm \
  -e INPUT_IMAGE="$YOUR_IMAGE_NAME" \
  -e INPUT_SIZE="$YOUR_SIZE_LIMIT" \
  wemakeservices/docker-image-size-limit

Should I use it?

You can use this script instead:

LIMIT=1024  # adjust at your will
IMAGE='your-image-name:latest'

SIZE="$(docker image inspect "$IMAGE" --format='{{.Size}}')"
test "$SIZE" -gt "$LIMIT" && echo 'Limit exceeded'; exit 1 || echo 'Ok!'

But I prefer to reuse tools over custom bash scripts here and there.

License

MIT.

More Repositories

1

wemake-python-styleguide

The strictest and most opinionated python linter ever!
Python
2,417
star
2

wemake-django-template

Bleeding edge django template focused on code quality and security.
Python
1,933
star
3

django-split-settings

Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files.
Python
1,031
star
4

wemake-vue-template

Bleeding edge vue template focused on code quality and developer happiness.
TypeScript
730
star
5

django-test-migrations

Test django schema and data migrations, including migrations' order and best practices.
Python
490
star
6

wemake-python-package

Bleeding edge cookiecutter template to create new python packages
Python
395
star
7

flake8-eradicate

Flake8 plugin to find commented out or dead code
Python
304
star
8

dotenv-linter

☺️ Linting dotenv files like a charm!
Python
270
star
9

caddy-gen

Automated Caddy reverse proxy for docker containers
Shell
229
star
10

recase

♻️ Convert strings to any case.
Elixir
215
star
11

nuxt-imagemin

Nuxt module to minify your images. Works with: png, jpeg, gif, and svg
JavaScript
178
star
12

ecto_autoslug_field

Automatically create slugs for Ecto schemas.
Elixir
147
star
13

jekyll-theme-hackcss

Dead simple CSS framework now with Jekyll.
HTML
123
star
14

flake8-broken-line

🚨 Flake8 plugin to forbid backslashes (\) for line breaks
Python
108
star
15

kira-dependencies

🐿 Kira's micro-bot to update project dependencies
Ruby
102
star
16

dump-env

A utility tool to create .env files
Python
97
star
17

wemake-frontend-styleguide

Set of the strictest linters for your next frontend app
JavaScript
74
star
18

kira

🐿️ Project management framework with deep philosophy underneath
Elixir
69
star
19

coverage-conditional-plugin

Conditional coverage based on any rules you define!
Python
63
star
20

meta

Home of Repeatable Software Development Process
HTML
51
star
21

pravda

Python type-checker written in Rust
Makefile
33
star
22

nuxt-babel

Use normal .babelrc file with your Nuxt app
JavaScript
33
star
23

asyncio-redis-rate-limit

Rate limiter for async functions using Redis as a backend.
Python
30
star
24

vue-material-input

Simple implementation of Material Input with no dependencies
Vue
24
star
25

vue-analytics-facebook-pixel

A small wrapper around Facebook Pixel API
JavaScript
23
star
26

mypy-extras

A collection of extra types and features for mypy
Python
22
star
27

caddy-docker

Docker image for Caddy
Dockerfile
19
star
28

awesome-microtasking

List of awesome resources and companies that practice microtasking
15
star
29

jinja2-git

Jinja2 extension to handle git-specific things
Python
15
star
30

safe-assert

Safe and composable assert for Python that can be used together with optimised mode
Python
13
star
31

kira-stale

🐿️ Kira's micro-bot to fight with stale GitLab issues and merge requests
Procfile
13
star
32

pytest-modified-env

Pytest plugin to fail a test if it leaves modified `os.environ` afterwards.
Python
11
star
33

vue-material-ripple

Simple material ripple effect wrapped in a component
Vue
11
star
34

remark-lint-are-links-valid

This package allows to perform multiple checks on your links
JavaScript
11
star
35

wemake-django-rest

Create Django REST APIs the right way, no magic intended
HTML
11
star
36

wemake-dind

Our docker-in-docker image with Python
Dockerfile
10
star
37

stylelint-config-strict-scss

Deprecated, use wemake-frontend-styleguide instead
JavaScript
8
star
38

kira-review

🐿️ Kira's micro-bot to review merge requests before real humans
Ruby
7
star
39

django-pre-deploy-checks

Django checks that you should run on application deploy
Python
5
star
40

mimesis-cloud

Python
5
star
41

kira-release

🐿️ Kira's micro-bot to release your code and track changes
JavaScript
5
star
42

vue-material-radio

Simple implementation of Material Radio Button with no dependencies
Vue
4
star
43

eslint-config-flowtype-essential

Deprecated, use wemake-frontend-styleguide instead
JavaScript
4
star
44

kira-setup

🐿 Kira's micro-bot to setup new projects
Python
3
star
45

remark-lint-list-item-punctuation

This package allows to check either a list item ends with a period.
JavaScript
3
star
46

eslint-config-jsdoc-essential

Deprecated, use wemake-frontend-styleguide instead
JavaScript
2
star
47

.github

GitHub metadata
1
star
48

wemake-services.github.io

Company's website. As minimal as possible.
JavaScript
1
star