watchtower/dockerfiles/Dockerfile.dev-self-contained
2025-02-08 11:22:50 -07:00

54 lines
1.7 KiB
Text

#
# Builder
#
FROM golang:alpine as builder
# use version (for example "v0.3.3") or "main"
ARG WATCHTOWER_VERSION=main
# Pre download required modules to avoid redownloading at each build thanks to docker layer caching.
# Copying go.mod and go.sum ensure to invalid the layer/build cache if there is a change in module requirement
WORKDIR /watchtower
COPY go.mod .
COPY go.sum .
RUN go mod download
RUN apk add --no-cache \
alpine-sdk \
ca-certificates \
git \
tzdata
COPY . /watchtower
RUN \
cd /watchtower && \
\
GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-extldflags '-static' -X github.com/nicholas-fedor/watchtower/internal/meta.Version=$(git describe --tags)" . && \
GO111MODULE=on go test ./... -v
#
# watchtower
#
FROM scratch
LABEL "com.centurylinklabs.watchtower"="true"
LABEL "org.opencontainers.image.url"="https://nicholas-fedor.github.io/watchtower/" \
"org.opencontainers.image.documentation"="https://nicholas-fedor.github.io/watchtower/" \
"org.opencontainers.image.source"="https://github.com/nicholas-fedor/watchtower" \
"org.opencontainers.image.licenses"="Apache-2.0" \
"org.opencontainers.image.title"="Watchtower" \
"org.opencontainers.image.description"="A process for automating Docker container base image updates." \
"org.opencontainers.image.base.name"="alpine"
# copy files from other container
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /watchtower/watchtower /watchtower
HEALTHCHECK CMD [ "/watchtower", "--health-check"]
ENTRYPOINT ["/watchtower"]