Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeremyhuiskamp/golang-docker-scratch
Recipe for go binary in scratch docker container with up-to-date tls certs and timezone data
https://github.com/jeremyhuiskamp/golang-docker-scratch
docker golang
Last synced: about 1 month ago
JSON representation
Recipe for go binary in scratch docker container with up-to-date tls certs and timezone data
- Host: GitHub
- URL: https://github.com/jeremyhuiskamp/golang-docker-scratch
- Owner: jeremyhuiskamp
- License: unlicense
- Created: 2017-08-17T10:47:47.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2022-11-01T16:50:43.000Z (about 2 years ago)
- Last Synced: 2024-08-01T13:29:59.168Z (4 months ago)
- Topics: docker, golang
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 101
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ccamel - jeremyhuiskamp/golang-docker-scratch - Recipe for go binary in scratch docker container with up-to-date tls certs and timezone data (Go)
README
# golang-docker-scratch
[![Build](https://github.com/jeremyhuiskamp/golang-docker-scratch/workflows/build/badge.svg)](https://github.com/jeremyhuiskamp/golang-docker-scratch/actions?query=workflow%3Abuild)
A recipe for go binaries in a scratch docker container with
up-to-date tls certs and timezone data.Golang binaries pair well with the docker scratch image, but
sometimes they need some help. In particular, it is common to
need a TLS certificate database and timezone data.Many tutorials suggest checking these files into your source
control, but this puts a maintenance burden on you to keep them
current.This recipe leverages docker multistage builds to source the
data from the latest version of the alpine linux package repository
without needing the rest of alpine in the final image.## Instructions
```
docker build -t golang-scratch-test --pull . && docker run -it --rm golang-scratch-test
```## External tzdata
The default Dockerfile uses [time/tzdata](https://golang.org/pkg/time/tzdata/)
to embed the zone info included in the go distribution.
`Dockerfile.externaltz` shows an example of how to source the zone database
from alpine instead. The external database takes up a bit more space but might
be desirable if, eg, you are stuck on an old golang version for some reason but
need a more current database, or want to use it from multiple go binaries in
the same image.