{"id":21338679,"url":"https://github.com/duaraghav8/dockershrink-cli","last_synced_at":"2025-07-12T14:31:04.501Z","repository":{"id":263943114,"uuid":"883136788","full_name":"duaraghav8/dockershrink-cli","owner":"duaraghav8","description":"Dockershrink is an AI-powered tool to reduce the size of your Docker Images. This project is the official Client for Dockershrink platform.","archived":false,"fork":false,"pushed_at":"2024-11-19T11:10:50.000Z","size":9351,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-21T05:39:28.884Z","etag":null,"topics":["docker","docker-image","optimization","size-optimization"],"latest_commit_sha":null,"homepage":"https://dockershrink.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/duaraghav8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-04T12:48:55.000Z","updated_at":"2024-11-19T11:35:56.000Z","dependencies_parsed_at":"2024-11-21T05:39:33.502Z","dependency_job_id":"a96f3a80-3087-498a-81f3-cfcf2dff2858","html_url":"https://github.com/duaraghav8/dockershrink-cli","commit_stats":null,"previous_names":["duaraghav8/dockershrink-cli"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duaraghav8%2Fdockershrink-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duaraghav8%2Fdockershrink-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duaraghav8%2Fdockershrink-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duaraghav8%2Fdockershrink-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duaraghav8","download_url":"https://codeload.github.com/duaraghav8/dockershrink-cli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225825268,"owners_count":17529905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-image","optimization","size-optimization"],"created_at":"2024-11-22T00:34:31.924Z","updated_at":"2024-11-22T00:34:32.594Z","avatar_url":"https://github.com/duaraghav8.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dockershrink CLI\n\n![Typical interaction with dockershrink CLI](./static/dockershrink-how-it-works.gif)\n\nOfficial commandline application to interact with the [Dockershrink](https://dockershrink.com) backend.\n\n**Dockershrink is a SaaS platform that helps you reduce the size of your Nodejs Docker images by applying code optimizations.**\n\nIt combines the power of traditional rule-based analysis with Generative AI to yield state-of-the-art optimizations for your images :brain:\n\n\u003e [!IMPORTANT]\n\u003e Dockershrink is in **BETA** and is **FREE** to use.\n\u003e \n\u003e We would love to hear what you think! You can provide your feedback from your [dockershrink dashboard](https://dockershrink.com/dashboard) or [Create an Issue](https://github.com/duaraghav8/dockershrink-cli/issues) in this repository.\n\n## Why does dockershrink exist?\nEvery org using containers in development or production environments understands the pain of managing hundreds or even thousands of BLOATED Docker images in their infrastructure.\n\nBut not everyone realizes that by just implementing some basic techniques, they can reduce the size of a 1GB Docker image down to **as little as 100 MB**!\n\n([I also made a video on how to do this.](https://youtu.be/vHBHxQfK6cM))\n\nImagine the costs saved in storage \u0026 data transfer, decrease in build times AND the productivity gains for developers :exploding_head:\n\nDockershrink aims to auomatically apply advanced optimization techniques such as Multistage builds, Light base images, removing unused dependencies, etc. so that developers \u0026 devops engineers don't have to waste time doing so and everybody still reaps the benefits!\n\nYou're welcome :wink:\n\n## How it works\nThe CLI is the primary user-facing application of dockershrink.\n\nWhen you invoke it on a project, it communicates with the Dockershrink platform to analyze some of your project files.\n\nCurrently, these files are:\n\n:point_right: `Dockerfile`\n\n:point_right: `package.json`\n\n:point_right: `.dockerignore`\n\nIt then creates a new directory called `dockershrink.optimized` inside the project, which contains modified versions of your files that will result in a smaller Docker Image.\n\nThe CLI outputs a list of actions it took on your files.\n\nIt may also include suggestions on further improvements you could make.\n\n## Setup\nIf you haven't already, [signup for an account](https://dockershrink.com) and get your API Key from your dashboard. Then proceed with the below steps.\n\n1. Download the pre-built CLI for your platform from the [Releases](https://github.com/duaraghav8/dockershrink-cli/releases) page.\n\nOn MacOS, use brew to install the CLI:\n```bash\nbrew install duaraghav8/tap/dockershrink\n```\n\nAlternatively, you can clone this repository and build the binary yourself by following the build instructions below.\n\n2. Rename your binary to `dockershrink` and make sure that the binary is in your `PATH` environment variable.\n\nFor example, on MacOS and Linux, you could copy the binary to your local bin directory using\n```bash\ncp ./dockershrink /usr/local/bin/dockershrink\n```\n\n3. Check that everything is setup by running `dockershrink help`.\n\n4. Initialize dockershrink with your API Key.\n\nCopy your API Key from your dashboard once you log into dockershrink.\nThen run the following command in your terminal:\n\n```bash\ndockershrink init --api-key \u003cpaste your api key here\u003e\n```\n\nThis is a one-time step which creates a `.dsconfig.json` file inside your home directory.\n\nIf your API key changes, simply run `init` again with the new api key to update it.\n\nCongratulations! Your installation is now complete!\n\n## Usage\nNavigate into the root directory of one of your Node.js projects and run the simplest command:\n\n```bash\ndockershrink optimize\n```\n\nDockershrink will create a new directory with the optimized files and output the actions taken and (maybe) some more suggestions.\n\nFor more information on the `optimize` command, run\n```bash\ndockershrink help optimize\n```\n\n### Using AI Features\n\n\u003e [!NOTE]\n\u003e Using AI features is optional, but **highly recommended** for more customized and powerful optimizations.\n\u003e\n\u003e Currently, you need to supply your own openai api key, so even though Dockershrink itself is free, openai usage might incur some cost for you.\n\nBy default, dockershrink only runs rule-based analysis to optimize your image definition.\n\nIf you want to enable AI, you must supply your own [OpenAI API Key](https://openai.com/index/openai-api/).\n\n```bash\ndockershrink optimize --openai-api-key \u003cyour openai api key\u003e\n\n# Alternatively, you can supply the key as an environment variable\nexport OPENAI_API_KEY=\u003cyour openai api key\u003e\ndockershrink optimize\n```\n\n\u003e [!NOTE]\n\u003e Dockershrink does not store your OpenAI API Key.\n\u003e\n\u003e So you must provide your key every time you want \"optimize\" to enable AI features.\n\n### Default file paths\nBy default, the CLI looks for the files to optimize in the current directory.\n\nYou can also specify the paths to all files using options (see `dockershrink help optimize` for the available options).\n\n## Build from source\n\n### Prerequisites\n\n- Clone this repository on to your local machine.\n- Make sure [Golang](https://golang.org/dl/) is installed on your system (at least version 1.23)\n- Make sure [Docker](https://www.docker.com/get-started) installed on your system and the Docker daemon is running.\n- Install [GoReleaser](https://goreleaser.com/) (at least version 2.4)\n\n### Build for local testing\n```bash\n# Single binary\ngoreleaser build --single-target --clean --snapshot\n\n# All binaries\ngoreleaser release --snapshot --clean\n```\n\n### Create a new release\n1. Create a Git Tag with the new version\n\n```bash\ngit tag -a v0.1.0 -m \"Release version 0.1.0\"\ngit push origin v0.1.0\n```\n\n2. Release\n```bash\n# Make sure GPG is present on your system and you have a default key which is added to Github.\n\n# set your github access token\nexport GITHUB_TOKEN=\"\u003cyour GH token\u003e\"\n\ngoreleaser release --clean\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduaraghav8%2Fdockershrink-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduaraghav8%2Fdockershrink-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduaraghav8%2Fdockershrink-cli/lists"}