{"id":19196026,"url":"https://github.com/acj/depender","last_synced_at":"2025-08-15T21:34:49.349Z","repository":{"id":66824237,"uuid":"220717289","full_name":"acj/depender","owner":"acj","description":"A tool for precompiling Go dependencies during Docker builds","archived":false,"fork":false,"pushed_at":"2020-04-05T19:27:54.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-23T04:42:40.828Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acj.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":"2019-11-09T23:34:25.000Z","updated_at":"2020-04-05T19:27:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"0a6aad4c-51be-4837-bd0a-819313374141","html_url":"https://github.com/acj/depender","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/acj/depender","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acj%2Fdepender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acj%2Fdepender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acj%2Fdepender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acj%2Fdepender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acj","download_url":"https://codeload.github.com/acj/depender/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acj%2Fdepender/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270631863,"owners_count":24619384,"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","status":"online","status_checked_at":"2025-08-15T02:00:12.559Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-09T12:12:15.668Z","updated_at":"2025-08-15T21:34:49.330Z","avatar_url":"https://github.com/acj.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# depender\n\nA tool for precompiling Go dependencies during Docker builds\n\nDownloading and compiling the dependencies for your Go code can take a while. And if you're building container images from a Dockerfile, the problem is made worse by Docker's caching system: you need to copy your app code into the container in order to fetch and build its dependencies, but the cache gets invalidated every time you make the slightest change to your code. If an app depends on larger Go packages like [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes) or [aws-sdk-go](https://github.com/aws/aws-sdk-go), the build might take several minutes. Every time.\n\ndepender solves this problem by generating a Go source file that contains only imports. This file can be compiled after copying `go.{mod,sum}` but _before_ copying app code so that the slow dependency compilation step remains cached.\n\n## Quick start\n\n```\n$ go get github.com/acj/depender\n$ depender -h\nUsage of depender:\n  -exclude string\n        package paths (or sub-strings) to exclude\n  -output string\n        path to output source file (default \"deps.go\")\n\n```\n\n## Usage\n\nFirst, use depender to generate a source file that includes the dependencies for your app's packages.\n\n```\n$ cd my-go-app\n$ depender ./...\nDummy source file written to deps.go\n```\n\nThen run `go build` on the dummy source file near top of your Dockerfile to compile the dependencies:\n\n```\nFROM golang:...\n\n# Precompile dependencies\nCOPY go.mod go.sum ./\nCOPY deps.go ./\nRUN go build deps.go \u0026\u0026 rm deps.go\n\n# Now, copy your app source\nCOPY . .\n\n...\n```\n\nBecause the dependencies are compiled before your app's source code is copied, they will remain cached until you update go.mod, go.sum, or deps.go.\n\nThe `deps.go` file should be checked into version control. It contains a `+build ignore` directive so that it won't be picked up by the normal build tooling.\n\n### Usage with `go generate`\n\nIf your dependencies change often, depender can be paired with `go generate` to streamline the workflow. For example, you can create a file containing the following:\n\n```go\n//go:generate go run github.com/acj/depender ./...\n```\n\nThen, running `go generate` will update `deps.go` with the current list of dependencies.\n\n## Does it help?\n\nFor a recent project that imported kubernetes/kubernetes, aws-sdk-go, and several other nontrivial packages, this reduced my incremental container build times from ~110 seconds to roughly 15 seconds.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facj%2Fdepender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facj%2Fdepender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facj%2Fdepender/lists"}