From 545c76f0111f542f24c2d2ee6c1aa5ecf57ee896 Mon Sep 17 00:00:00 2001 From: Victor Moura Date: Tue, 7 Jan 2020 13:59:19 -0300 Subject: [PATCH 1/4] Adds self-contained dev Dockerfile --- Dockerfile.dev-self-contained | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Dockerfile.dev-self-contained diff --git a/Dockerfile.dev-self-contained b/Dockerfile.dev-self-contained new file mode 100644 index 0000000..307ffbe --- /dev/null +++ b/Dockerfile.dev-self-contained @@ -0,0 +1,38 @@ +# +# 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 + +COPY . /watchtower + +RUN \ + 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 /watchtower/watchtower /watchtower + +ENTRYPOINT ["/watchtower"] From 503d6933773d2ba34bdffa23bab0f896c8e3a97f Mon Sep 17 00:00:00 2001 From: Victor Moura Date: Wed, 8 Jan 2020 18:51:04 -0300 Subject: [PATCH 2/4] Moved dockerfiles to an exclusive folder --- Dockerfile => dockerfiles/Dockerfile | 0 .../Dockerfile.dev-self-contained | 0 .../Dockerfile.self-contained | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename Dockerfile => dockerfiles/Dockerfile (100%) rename Dockerfile.dev-self-contained => dockerfiles/Dockerfile.dev-self-contained (100%) rename Dockerfile.self-contained => dockerfiles/Dockerfile.self-contained (100%) diff --git a/Dockerfile b/dockerfiles/Dockerfile similarity index 100% rename from Dockerfile rename to dockerfiles/Dockerfile diff --git a/Dockerfile.dev-self-contained b/dockerfiles/Dockerfile.dev-self-contained similarity index 100% rename from Dockerfile.dev-self-contained rename to dockerfiles/Dockerfile.dev-self-contained diff --git a/Dockerfile.self-contained b/dockerfiles/Dockerfile.self-contained similarity index 100% rename from Dockerfile.self-contained rename to dockerfiles/Dockerfile.self-contained From 85d39ddcd11824ad7fc1e316b028a5b8b93be820 Mon Sep 17 00:00:00 2001 From: Victor Moura Date: Wed, 8 Jan 2020 19:42:08 -0300 Subject: [PATCH 3/4] Edits goreleaser to match exclusive dockerfiles folder --- goreleaser.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/goreleaser.yml b/goreleaser.yml index 4fa3841..927cdcd 100644 --- a/goreleaser.yml +++ b/goreleaser.yml @@ -29,7 +29,7 @@ dockers: goos: linux goarch: amd64 goarm: '' - dockerfile: Dockerfile + dockerfile: dockerfiles/Dockerfile image_templates: - containrrr/watchtower:amd64-{{ .Version }} - containrrr/watchtower:amd64-latest @@ -39,7 +39,7 @@ dockers: goos: linux goarch: 386 goarm: '' - dockerfile: Dockerfile + dockerfile: dockerfiles/Dockerfile image_templates: - containrrr/watchtower:i386-{{ .Version }} - containrrr/watchtower:i386-latest @@ -49,7 +49,7 @@ dockers: goos: linux goarch: arm goarm: 6 - dockerfile: Dockerfile + dockerfile: dockerfiles/Dockerfile image_templates: - containrrr/watchtower:armhf-{{ .Version }} - containrrr/watchtower:armhf-latest @@ -59,7 +59,7 @@ dockers: goos: linux goarch: arm64 goarm: '' - dockerfile: Dockerfile + dockerfile: dockerfiles/Dockerfile image_templates: - containrrr/watchtower:arm64v8-{{ .Version }} - containrrr/watchtower:arm64v8-latest From 798f48aab8f3bf80aab7a1a9770a87078d592905 Mon Sep 17 00:00:00 2001 From: Victor Moura Date: Wed, 8 Jan 2020 20:02:47 -0300 Subject: [PATCH 4/4] Adds development self-contained builds instructions to CONTRIBUTING.md --- CONTRIBUTING.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db50329..82b1b1b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,4 +25,14 @@ go build # compiles and packages an executable bin go test ./... -v # runs tests with verbose output ./watchtower # runs the application (outside of a container) ``` + If you dont have it enabled, you'll either have to prefix each command with `GO111MODULE=on` or run `export GO111MODULE=on` before running the commands. [You can read more about modules here.](https://github.com/golang/go/wiki/Modules) + +To build a Watchtower image of your own, use the self-contained Dockerfiles. As the main Dockerfile, they can be found in `dockerfiles/`: +- `dockerfiles/Dockerfile.dev-self-contained` will build an image based on your current local Watchtower files. +- `dockerfiles/Dockerfile.self-contained` will build an image based on current Watchtower's repository on GitHub. + +e.g.: +```bash +sudo docker build . -f dockerfiles/Dockerfile.dev-self-contained -t containrrr/watchtower # to build an image from local files +``` \ No newline at end of file