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 diff --git a/Dockerfile b/dockerfiles/Dockerfile similarity index 100% rename from Dockerfile rename to dockerfiles/Dockerfile diff --git a/dockerfiles/Dockerfile.dev-self-contained b/dockerfiles/Dockerfile.dev-self-contained new file mode 100644 index 0000000..307ffbe --- /dev/null +++ b/dockerfiles/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"] 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 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