mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-16 15:10:12 +01:00
Add Dockerfile using multi-stage build
This commit is contained in:
parent
fcdd601389
commit
51f2acb69b
1 changed files with 39 additions and 0 deletions
39
Dockerfile.multistage-build
Normal file
39
Dockerfile.multistage-build
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
#
|
||||||
|
# Builder
|
||||||
|
#
|
||||||
|
|
||||||
|
FROM golang:alpine as builder
|
||||||
|
|
||||||
|
# use version (for example "v0.3.3") or "master"
|
||||||
|
ARG WATCHTOWER_VERSION=master
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
apk add --no-cache \
|
||||||
|
alpine-sdk \
|
||||||
|
ca-certificates \
|
||||||
|
git \
|
||||||
|
tzdata && \
|
||||||
|
\
|
||||||
|
mkdir --parents $GOPATH/src/github.com/containrrr && \
|
||||||
|
cd $GOPATH/src/github.com/containrrr && \
|
||||||
|
git clone --branch "${WATCHTOWER_VERSION}" https://github.com/containrrr/watchtower.git && \
|
||||||
|
cd watchtower && \
|
||||||
|
\
|
||||||
|
GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' . && \
|
||||||
|
GO111MODULE=on go test ./... -v
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# watchtower
|
||||||
|
#
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
LABEL "com.centurylinklabs.watchtower"="true"
|
||||||
|
|
||||||
|
# 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 /go/src/github.com/containrrr/watchtower/watchtower /watchtower
|
||||||
|
|
||||||
|
ENTRYPOINT ["/watchtower"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue