Skip to content

Instantly share code, notes, and snippets.

@karma-git
Created May 10, 2022 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karma-git/ca25b6f373a0c6648e4293de9815ee9a to your computer and use it in GitHub Desktop.
Save karma-git/ca25b6f373a0c6648e4293de9815ee9a to your computer and use it in GitHub Desktop.
Various Dockerfile-s

Various Dockerfile-s

  • alertmanager-bot.Dockerfile - rootless scratch version of alertmanager-bot
  • ...
FROM alpine/git:v2.34.2 as build
WORKDIR /
ARG AM_BOT_VERSION="0.4.3"
RUN \
apk add --no-cache ca-certificates~=20211220 \
&& git clone --branch ${AM_BOT_VERSION} https://github.com/metalmatze/alertmanager-bot.git am-repo \
&& wget -c https://github.com/metalmatze/alertmanager-bot/releases/download/${AM_BOT_VERSION}/alertmanager-bot-${AM_BOT_VERSION}-linux-amd64 -O alertmanager-bot
RUN addgroup --gid 10001 app \
&& adduser \
--uid 10001 \
--home /home/app \
--shell /bin/ash \
--ingroup app \
--disabled-password \
app
# final
FROM scratch
WORKDIR /
ENV TEMPLATE_PATHS=/templates/default.tmpl
# copy certs
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
# copy non-root user-data
COPY --from=build /etc/passwd /etc/passwd
# copy binary
COPY --from=build --chmod=755 /alertmanager-bot ./
# copy alert template
COPY --from=build /am-repo/default.tmpl /templates/default.tmpl
# user app
USER 10001
# default alertmanager-bot port
EXPOSE 8080
ENTRYPOINT [ "./alertmanager-bot" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment