Skip to content
This repository was archived by the owner on Jun 14, 2023. It is now read-only.

Add official Dockerfile, build official images to GitHub Packages#47

Open
jinnatar wants to merge 3 commits intoimgix:masterfrom
jinnatar:docker
Open

Add official Dockerfile, build official images to GitHub Packages#47
jinnatar wants to merge 3 commits intoimgix:masterfrom
jinnatar:docker

Conversation

@jinnatar
Copy link

There are 15 unofficial Docker images on DockerHub, so clearly there's demand for an image. All of them are either wildly out of date or do not publish their Dockerfile though, which is sub-optimal.

This PR adds a simple official Dockerfile and automated build action. An example of the automated build and an image it procudes can be seen in the fork where I'm proposing the merge from: https://ghcr.io/artanicus/prometheus-am-executor

Pushes to the master branch will tag the images with latest, all pushes to all branches are tagged with branch_name-6-digit-hash-from-commit and any git tags are tagged as-is. So for example a release tagged as 1.0 would result in an image: ghcr.io/imgix/prometheus-am-executor:1.0

- Bunary is built against go1.17.x
- But served with just a plan alpine:latest image
- As a result the final image size is < 19 MiB
Images are pushed into the free GitHub registry and become evailable as
"packages" for the repository.
Copy link
Collaborator

@colakong colakong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base image is alpine, and the go build steps produce a dynamically-linked library. In this scenario, if libc6-compat is not installed, the container image will produce a "No such file or directory" error when run.

An alternative to this would be to build a static binary by setting CGO_ENABLED=0 when building the binary ^^

COPY countermap ./countermap
RUN go build

FROM alpine:latest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM alpine:latest
FROM alpine:latest
# This is needed, for a dynamically-linked go binary when using alpine as a base image.
# If you don't want to install this, then set CGO_ENABLED=0 environment variable when issuing 'go build'
RUN apk add --no-cache libc6-compat

@colakong
Copy link
Collaborator

colakong commented Feb 4, 2022

Also, thankyou for putting this together @Artanicus 😸

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants