Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Chainguard images for build and runtime #2102

Closed
wants to merge 5 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# syntax=docker/dockerfile:latest
## build ergo binary
FROM docker.io/golang:1.21-alpine AS build-env

RUN apk upgrade -U --force-refresh --no-cache && apk add --no-cache --purge --clean-protected -l -u make git
FROM cgr.dev/chainguard/go:latest AS build-env

# copy ergo source
WORKDIR /go/src/github.com/ergochat/ergo
Expand All @@ -15,34 +14,33 @@ RUN sed -i 's/^\(\s*\)\"127.0.0.1:6667\":.*$/\1":6667":/' /go/src/github.com/erg
# compile
RUN make install

## tmp container for collecting files
FROM scratch AS tmp

# collect all files
COPY --from=build-env /root/go/bin/ergo \
/go/src/github.com/ergochat/ergo/default.yaml \
/go/src/github.com/ergochat/ergo/distrib/docker/run.sh \
/ircd-bin/
COPY --from=build-env /go/src/github.com/ergochat/ergo/languages /ircd-bin/languages/
COPY --from=build-env /go/src/github.com/ergochat/ergo/ergo.motd /ircd/ergo.motd

## build ergo container
FROM docker.io/alpine:3.13
FROM cgr.dev/chainguard/busybox:latest-glibc AS runtime
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, any reason to prefer glibc over musl here? It sounds like musl is the default: https://edu.chainguard.dev/chainguard/chainguard-images/reference/busybox/#image-variants

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Potential workaround for your issue with faccessat2(2) as I figured maybe it was an alpine/musl related issue and the default latest tag uses alpine and musl as a base instead of wolfi and glibc.

However if you can still reproduce it with this PR then it would seem it's not a very good workaround :)

Copy link
Member

Choose a reason for hiding this comment

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

Oh, my mistake --- I reproduced the issue using Alpine, not this branch. I'm no longer very concerned about the issue, since Docker 20.10 should have an effective workaround (discussion on #2103)


# metadata
LABEL maintainer="Daniel Oaks <[email protected]>,Daniel Thamdrup <[email protected]>" \
LABEL maintainer="Daniel Oaks <[email protected]>,Daniel Thamdrup <[email protected]>" \
description="Ergo is a modern, experimental IRC server written in Go"

# standard ports listened on
EXPOSE 6667/tcp 6697/tcp

# ergo itself
COPY --from=build-env /go/bin/ergo \
/go/src/github.com/ergochat/ergo/default.yaml \
/go/src/github.com/ergochat/ergo/distrib/docker/run.sh \
/ircd-bin/
COPY --from=build-env /go/src/github.com/ergochat/ergo/languages /ircd-bin/languages/
COPY --from=tmp --chown=nonroot:nonroot / /

# running volume holding config file, db, certs
VOLUME /ircd
WORKDIR /ircd

# default motd
COPY --from=build-env /go/src/github.com/ergochat/ergo/ergo.motd /ircd/ergo.motd

# launch
ENTRYPOINT ["/ircd-bin/run.sh"]

# # uncomment to debug
# RUN apk add --no-cache bash
# RUN apk add --no-cache vim
# CMD /bin/bash