{"id":22186045,"url":"https://github.com/twhiston/micro-golang","last_synced_at":"2026-05-08T17:31:37.766Z","repository":{"id":92519867,"uuid":"93411842","full_name":"twhiston/micro-golang","owner":"twhiston","description":"golang microservice environment with testing and toolchain contexts","archived":false,"fork":false,"pushed_at":"2018-02-28T16:32:21.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"v2","last_synced_at":"2025-06-07T05:07:22.176Z","etag":null,"topics":["codeship","docker","drone-ci","gitlab-ci","golang","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/twhiston.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-06-05T14:21:02.000Z","updated_at":"2024-10-07T20:52:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"d08018bc-79d3-4ce9-96b8-78ad5acaf6f5","html_url":"https://github.com/twhiston/micro-golang","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/twhiston/micro-golang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twhiston%2Fmicro-golang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twhiston%2Fmicro-golang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twhiston%2Fmicro-golang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twhiston%2Fmicro-golang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twhiston","download_url":"https://codeload.github.com/twhiston/micro-golang/tar.gz/refs/heads/v2","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twhiston%2Fmicro-golang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32790188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["codeship","docker","drone-ci","gitlab-ci","golang","testing-tools"],"created_at":"2024-12-02T10:19:49.812Z","updated_at":"2026-05-08T17:31:37.752Z","avatar_url":"https://github.com/twhiston.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# micro-golang\n##### A super lightweight microservice container for golang applications, including ci testing context and toolchain image\nVersion 2\n\n[ ![Codeship Status for twhiston/micro-golang](https://app.codeship.com/projects/cb4b5360-2c28-0135-d4a4-7229e0f954fc/status?branch=master)](https://app.codeship.com/projects/224201)\n\n## Contexts\n\nAll containers are based on Alpine 3.7 and Golang 1.9.\n\nAll contexts fully support application installation either via `go get` or `dep`.\nInstall type detection is done on the presence of a `Gopkg.lock` file in your app root.\n\nAll containers copy your application source to `/go/src/app` and install it to `/usr/local/bin/app`.\nThe default container entrypoint will be your application.\n\n### Prod\n\nThe `prod` image is a basic ONBUILD production image that can be used for golang containers,\nit installs the application and toolchain in a single run command so that they can be removed\ncleanly and the image size minimized.\n\nTo make use of this image you must derive a Dockerfile from it.\nThe minimal implementation of a working Dockerfile would be:\n```\nFROM tomwhiston/micro-golang:prod\n```\n\nThe image contains a runtime user which could also be told to run the container in your Dockerfile.\nYou should set this if you plan to use this image on Openshift or another root user restricting platform\n```\nFROM tomwhiston/micro-golang:prod\nUSER 1001\n```\n\nThe image does NOT expose any ports by default, you must do this in your application Dockerfile\n\nContainers built with this image will be alpine-image-size + application-binary-size.\n\n### Prodv3\n\nThe `prodv3` context is based around an ONBUILD multi-stage Dockerfile process, and uses 2 images.\nThe builder image contains the Golang toolchain (and dep) and builds your application, it is then injected into the runtime container.\nThe builder image is ~566MB in size, but because the toolchain is not required to be installed at build time, as long as you can cache the\nbuilder image on your ci/cd platform the overall build speed will be greatly reduced.\n\nThe minimal implementation of a working Dockerfile would be:\n```\nFROM tomwhiston/micro-golang:prodv3-builder AS builder\nFROM tomwhiston/micro-golang:prodv3-runtime\n```\nThis slightly unusual format is required for the ONBUILD instructions in the builder image to be triggered properly.\n\nUnlike the `prod` context the runtime image will run as USER 1001 as default.\n\nContainers built with this image will be alpine-image-size + application-binary-size.\n\n### Test\n\nThe `test` context is an ONBUILD test container for golang projects which additionally installs the following golang tools\n\n- godacov\n- goverage\n- cover\n- gometalinter\n\nto help with building and testing golang applications in a ci environment.\n\nThe minimal implementation of a working Dockerfile would be:\n```\nFROM tomwhiston/micro-golang:test\n```\n\nUnlike the other images this containers CMD is a testing script which exposes additional hook scripts which can be used to control the testing process.\n\nThese hooks are expected to be named bash scripts, and their default location is a `.mgl` folder in your application root. This location can be changed by setting the containers environmental variables\n\n#### Environmental Variables\n\nThe following environmental variables are set in the container and used to determine the location of scripts to run during the test process.\n\n- MGL_APP_ROOT=\"/go/src/app\"\n- MGL_INSTALL=true\n- MGL_TEST=true\n- MGL_LINT=true\n- MGL_CONFIG_PATH=\"/go/src/app/.mgl\"\n- MGL_LINT_CONFIG=\"gometalinter.json\"\n- MGL_SCRIPT_PRE_INSTALL=\"pre-install\"\n- MGL_SCRIPT_POST_DEPS=\"post-deps\" * only if install uses dep\n- MGL_SCRIPT_POST_INSTALL=\"post-run\" * only in prod container\n- MGL_SCRIPT_PRE_RUN=\"pre-run\" * only in test container\n- MGL_SCRIPT_POST_RUN=\"post-run\" * only in test container\n- MGL_SCRIPT_EXIT=\"exit\"\n\n\n`MGL_SCRIPT_*` variables are expected to point to scripts which can be sourced by `go/scripts/install.sh` and `go/scripts/test.sh`\n\n#### Test Flow\n\n- If existent run `MGL_SCRIPT_PRE_INSTALL`\n- If `$MGL_INSTALL == 'true'` install the application dependencies using either `go get` or `dep ensure`\n- If existent run `MGL_SCRIPT_PRE_RUN`\n- If `$MGL_TEST == 'true'` run the tests and generate coverage\n- If `$MGL_LINT == 'true'` then run gometalinter with optional config file `MGL_LINT_CONFIG` (note, if no config file is set micro-golang will always set the --vendor option)\n- If existent run `MGL_SCRIPT_POST_RUN`\n\nIf at any time the above sequence fails and exit is called it will be trapped and `MGL_SCRIPT_EXIT` will be called.\nAdditionally as part of the exit script if `CODACY_TOKEN` is set any coverage generated will be shipped to [Codacy](https://www.codacy.com)\n\nTip: As you need to supply your commit id to codacy and `MGL_SCRIPT_EXIT` is called before the coverage is posted you can easily make the exit script set the variable\n```\nexport COMMIT_ID=${CI_COMMIT_ID} #Your ci's commit id variable name\n```\n\nThe container additionally adds the script `/go/scripts/hold.sh` which you can use to hold a container open for debug purposes.\n\nThis container image will be ~835MB. As most of this comes from the parent the build process will be of good speed.\n\n## Development\n\nThe following dependencies are needed for developing micro-golang\n\n- go toolchain\n- docker\n- task\n- hadolint\n- shellcheck\n- goss\n\nCheck Taskfile.yml for the definition of all tasks for building, linting etc.... the project.\n\n### CI\n\nThe ci folder contains an image for testing micro-golang in a ci environment, this installs docker, goss and task\nand is used to build the containers on the ci (does not currently lint or shellcheck due to package unavailability)\n\nYour ci will need to make the docker socket (or a dind service) available for the image for the build process to work correctly.\n\n## v1 images\n\nv1 images will remain on docker hub with the v1 prefix, but will no longer be supported or updated\n(this will not be done until v2 is released)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwhiston%2Fmicro-golang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwhiston%2Fmicro-golang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwhiston%2Fmicro-golang/lists"}