{"id":13581710,"url":"https://github.com/sourcegraph/godockerize","last_synced_at":"2025-04-06T10:32:46.697Z","repository":{"id":57482770,"uuid":"113043560","full_name":"sourcegraph/godockerize","owner":"sourcegraph","description":"Build Docker images from Go packages","archived":false,"fork":true,"pushed_at":"2024-06-04T17:33:58.000Z","size":40,"stargazers_count":9,"open_issues_count":0,"forks_count":4,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-05T15:11:57.012Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"neelance/godockerize","license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sourcegraph.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}},"created_at":"2017-12-04T13:05:25.000Z","updated_at":"2022-11-23T13:09:37.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sourcegraph/godockerize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fgodockerize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fgodockerize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fgodockerize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fgodockerize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sourcegraph","download_url":"https://codeload.github.com/sourcegraph/godockerize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247470450,"owners_count":20944146,"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":[],"created_at":"2024-08-01T15:02:11.781Z","updated_at":"2025-04-06T10:32:44.910Z","avatar_url":"https://github.com/sourcegraph.png","language":"Go","readme":"# godockerize\n\ngodockerize builds a Dockerfile for a given Go project. The base image uses\nAlpine.\n\n### Usage\n\n```\n$ godockerize build github.com/path/to/your/go/main\n```\n\nWill generate a Dockerfile, build a Go binary for that package, and then build\nthe Dockerfile with the Go binary.\n\nRun `--help` to view the full list of options for customizing the program's\nbehavior.\n\n### Build tags\n\ngodockerize supports a number of build tags that can be used to customize the\ncontent of the generated Dockerfile. Add a `//docker:\u003ctagname\u003e` comment line to\nthe package being built to customize the behavior. Here are the tags:\n\n##### //docker:env\n\nAdding this to your Go binary:\n\n```go\n//docker:env TZ=UTC\n\npackage main\n```\n\nAdds an ENV command to the dockerfile:\n\n```\nENV TZ=UTC\n```\n\n##### //docker:expose\n\nExpose the provided ports via an EXPOSE command\n\n```go\n//docker:expose 5000\n```\n\n##### //docker:install\n\nInstall the provided packages. In addition, if a package name ends with `@edge`,\nthe edge apk repositories will be added to `/etc/apk/repositories`.\n\n```go\n//docker:install git@edge openssh-client\n```\n\nGenerates:\n\n```\n  FROM alpine:3.8\n  RUN echo -e \"@edge http://dl-cdn.alpinelinux.org/alpine/edge/main\" \u003e\u003e /etc/apk/repositories\n  RUN echo -e \"@edge http://dl-cdn.alpinelinux.org/alpine/edge/community\" \u003e\u003e /etc/apk/repositories\n  RUN apk add --no-cache ca-certificates git@edge mailcap openssh-client tini\n  USER myuser\n  ENTRYPOINT [\"/sbin/tini\", \"--\", \"/usr/local/bin/mybinary\"]\n  ADD mybinary /usr/local/bin/\n```\n\n##### //docker:repository\n\nCan be used to add other repository versions. Note as a special case, the `edge`\nrepository is automatically added as part of the `docker:install` step for any\npackages that end in `@edge`.\n\n```go\n//docker:repository v3.6\n```\n\nWill add these lines to the Dockerfile:\n\n```\n  RUN echo -e \"http://dl-cdn.alpinelinux.org/alpine/v3.6/main\\n\" \u003e\u003e /etc/apk/repositories \u0026\u0026 \\\n    echo -e \"http://dl-cdn.alpinelinux.org/alpine/v3.6/community\\n\" \u003e\u003e /etc/apk/repositories\n```\n\n##### //docker:run\n\nAdd custom commands to run in the Dockerfile.\n\n```go\n//docker:run apk add curl\n```\n\n##### //docker:user\n\nRun commands in the Dockerfile as a custom user.\n\n```go\n//docker:user myuser\n```\n\n```\nRUN addgroup -S myuser \u0026\u0026 adduser -S -G myuser -h /home/myuser myuser \u0026\u0026 mkdir -p /data/repos \u0026\u0026 chown -R myuser:myuser /data/repos\nUSER myuser\n```\n\n### Errata\n\nAlpine base images had a security vulnerability where apk installing/unpacking\nresources onto the filesystem could lead to RCE. That vulnerability has been\nfixed in Alpine 3.8.1. `godockerize` uses a base image that includes the\nsecurity patch.\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcegraph%2Fgodockerize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourcegraph%2Fgodockerize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcegraph%2Fgodockerize/lists"}