Merge ~ubuntu-docker-images/ubuntu-docker-images/+git/telegraf:20.04-resync-with-21.04-dockerfile into ~ubuntu-docker-images/ubuntu-docker-images/+git/telegraf:edge

Proposed by Bryce Harrington
Status: Merged
Merge reported by: Sergio Durigan Junior
Merged at revision: c5daf2651e840c185fee14941482fae1a91887e9
Proposed branch: ~ubuntu-docker-images/ubuntu-docker-images/+git/telegraf:20.04-resync-with-21.04-dockerfile
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/telegraf:edge
Diff against target: 73 lines (+31/-21)
1 file modified
Dockerfile (+31/-21)
Reviewer Review Type Date Requested Status
Sergio Durigan Junior Approve
Canonical Server Pending
Review via email: mp+400152@code.launchpad.net

Description of the change

This is a partial sync-up of the telegraf 20.04 branch to the changes on 21.04.

The build process for telegraf on 20.04 is substantially different from 21.04, so out of caution rather than copy the 21.04 Dockerfile and fixup, I manually made the corresponding refactoring changes but left the existing build system essentially as-is. Let me know if this should be done differently.

A few other things to call out. The 20.04 branch did not have a manifest, so I added the basic support there. However, the 21.04 image also had logic to include go packages. Is that needed here as well? I'm guessing the new golang-go and/or python dependencies were added for this?

In the 20.04 Dockerfile there is a "COPY . ." line that isn't in 21.04. I don't know what that does so left it in place, but can it be removed?

In building the image, I got an error regarding 'apt-get install ... /pkg/telegraf*.deb ...' due to "unsupported file given". Instead of using apt-get to install the .debs I used dpkg -i, and that seemed to resolve the issue.

With that change, I verified the branch builds the docker image successfully, locally. I'll appreciate your usual checking that it builds and runs ok for you too.

For ease of review of the remaining delta, here is a diff between the two Dockerfiles after my changes (and ignoring whitespace changes):

    https://paste.ubuntu.com/p/wKHFBMBJ6g/

To post a comment you must log in.
Revision history for this message
Bryce Harrington (bryce) wrote :

(Refreshed the pastebin)

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks for the MP, Bryce.

I am leaving a few comments here and there for small nits I found. I built and tested the image, and everything seems OK (modulo the manifest thing; see below).

For 21.04, since we have telegraf in the archive, the build process is much simpler because it's just a matter of apt-get installing the package. For 20.04, the situation is a bit more complex. We are still working with the SRU team in order to include telegraf into Focal, but it's not there yet. However, we do have the (yet to be) Focal telegraf package in a repository, so that's what the Dockerfile uses to build things (we could perhaps maintain this in a PPA, but I decided to just build everything from source). That's why you see the differences between the two releases.

For the manifest generation, as I mentioned below, I can look into it if you'd like. It's not entirely trivial and I already did it for 21.04, so it will be faster, I think. You can leave the existing hunk that generates the manifest from dpkg, because that will be useful as well.

I'm approving this, so after you fix the issues I pointed, feel free to merge it. Thanks.

review: Approve
Revision history for this message
Bryce Harrington (bryce) wrote :
Download full text (5.9 KiB)

On Wed, Mar 24, 2021 at 10:47:12PM -0000, Sergio Durigan Junior wrote:
> Review: Approve
>
> Thanks for the MP, Bryce.
>
> I am leaving a few comments here and there for small nits I found. I built and tested the image, and everything seems OK (modulo the manifest thing; see below).
>
> For 21.04, since we have telegraf in the archive, the build process is much simpler because it's just a matter of apt-get installing the package. For 20.04, the situation is a bit more complex. We are still working with the SRU team in order to include telegraf into Focal, but it's not there yet. However, we do have the (yet to be) Focal telegraf package in a repository, so that's what the Dockerfile uses to build things (we could perhaps maintain this in a PPA, but I decided to just build everything from source). That's why you see the differences between the two releases.
>
> For the manifest generation, as I mentioned below, I can look into it if you'd like. It's not entirely trivial and I already did it for 21.04, so it will be faster, I think. You can leave the existing hunk that generates the manifest from dpkg, because that will be useful as well.
>

Thanks, that'd be great. I pushed it as is, you can fix up at your leisure.

> I'm approving this, so after you fix the issues I pointed, feel free to merge it. Thanks.
>
> Diff comments:
>
> > diff --git a/Dockerfile b/Dockerfile
> > index 97b39b7..b99f9b1 100644
> > --- a/Dockerfile
> > +++ b/Dockerfile
> > @@ -1,37 +1,47 @@
> > -FROM ubuntu:focal AS builder
> > +FROM ubuntu:focal AS manifest-builder
>
> The name should remain "builder", since it's being used to build the full package, not only the manifest.

Done

> > COPY . .
> >
> > WORKDIR /src/telegraf
> >
> > -RUN apt-get update \
> > - && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
> > - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git dpkg-dev ca-certificates pristine-tar \
> > - && git clone https://git.launchpad.net/~ubuntu-server/ubuntu/+source/telegraf \
> > - && cd telegraf \
> > - && git branch pristine-tar origin/pristine-tar \
> > - && git checkout focal \
> > - && cp -a /adjust-telegraf-conf.patch debian/patches \
> > - && echo "adjust-telegraf-conf.patch" >> debian/patches/series \
> > - && sed -i 's@^EXCLUDE_TESTS.*@EXCLUDE_TESTS = github.com/influxdata/telegraf/plugins/inputs/http_response \
> > +RUN set -eux; \
> > + apt-get update; \
> > + DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y; \
> > + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
> > + dpkg-dev git ca-certificates pristine-tar; \
> > + git clone https://git.launchpad.net/~ubuntu-server/ubuntu/+source/telegraf; \
> > + cd telegraf; \
> > + git branch pristine-tar origin/pristine-tar; \
> > + git checkout focal; \
> > + cp -a /adjust-telegraf-conf.patch debian/patches/; \
> > + echo "adjust-telegraf-conf.patch" >> debian/patches/series; \
> > + sed -i 's@^EXCLUDE_TESTS.*@EXCLUDE_TESTS = github.com/influxdata/telegraf/plugins/inputs/http_response \
> > github.com/influxdata/telegraf/plugins/inputs/zipkin \
> > -github.com/influxdata/telegraf/plugins/outputs/prometheus_client ...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Dockerfile b/Dockerfile
2index 97b39b7..b99f9b1 100644
3--- a/Dockerfile
4+++ b/Dockerfile
5@@ -1,37 +1,47 @@
6-FROM ubuntu:focal AS builder
7+FROM ubuntu:focal AS manifest-builder
8
9 COPY . .
10
11 WORKDIR /src/telegraf
12
13-RUN apt-get update \
14- && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
15- && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git dpkg-dev ca-certificates pristine-tar \
16- && git clone https://git.launchpad.net/~ubuntu-server/ubuntu/+source/telegraf \
17- && cd telegraf \
18- && git branch pristine-tar origin/pristine-tar \
19- && git checkout focal \
20- && cp -a /adjust-telegraf-conf.patch debian/patches \
21- && echo "adjust-telegraf-conf.patch" >> debian/patches/series \
22- && sed -i 's@^EXCLUDE_TESTS.*@EXCLUDE_TESTS = github.com/influxdata/telegraf/plugins/inputs/http_response \
23+RUN set -eux; \
24+ apt-get update; \
25+ DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y; \
26+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
27+ dpkg-dev git ca-certificates pristine-tar; \
28+ git clone https://git.launchpad.net/~ubuntu-server/ubuntu/+source/telegraf; \
29+ cd telegraf; \
30+ git branch pristine-tar origin/pristine-tar; \
31+ git checkout focal; \
32+ cp -a /adjust-telegraf-conf.patch debian/patches/; \
33+ echo "adjust-telegraf-conf.patch" >> debian/patches/series; \
34+ sed -i 's@^EXCLUDE_TESTS.*@EXCLUDE_TESTS = github.com/influxdata/telegraf/plugins/inputs/http_response \
35 github.com/influxdata/telegraf/plugins/inputs/zipkin \
36-github.com/influxdata/telegraf/plugins/outputs/prometheus_client \\@' debian/rules \
37- && pristine-tar checkout ../telegraf_$(dpkg-parsechangelog -SVersion | sed 's/\(.*\)-.ubuntu.*/\1/').orig.tar.xz \
38- && DEBIAN_FRONTEND=noninteractive apt-get build-dep . -y \
39- && dpkg-buildpackage -us -uc
40+github.com/influxdata/telegraf/plugins/outputs/prometheus_client \\@' debian/rules; \
41+ pristine-tar checkout ../telegraf_$(dpkg-parsechangelog -SVersion | sed 's/\(.*\)-.ubuntu.*/\1/').orig.tar.xz; \
42+ DEBIAN_FRONTEND=noninteractive apt-get build-dep . -y; \
43+ dpkg-buildpackage -us -uc
44
45 FROM ubuntu:focal
46
47 ENV TZ UTC
48
49-COPY --from=builder /src/telegraf/telegraf*.deb /pkg/
50+COPY --from=manifest-builder /src/telegraf/telegraf*.deb /pkg/
51
52-RUN apt-get update \
53- && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
54- && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends /pkg/telegraf*.deb tzdata \
55+RUN set -eux; \
56+ apt-get update; \
57+ DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y; \
58+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
59+ tzdata; \
60+ dpkg -i /pkg/telegraf*.deb; \
61 # We don't need to keep the .deb packages around
62- && rm -rf /pkg \
63- && rm -rf /var/lib/apt/lists/*
64+ rm -rf /pkg; \
65+ rm -rf /var/lib/apt/lists/*; \
66+# smoke test
67+ telegraf --version; \
68+# create manifest
69+ mkdir -p /usr/share/rocks; \
70+ (echo "# os-release" && cat /etc/os-release && echo "# dpkg-query" && dpkg-query -f '${db:Status-Abbrev},${binary:Package},${Version},${source:Package},${Source:Version}\n' -W) > /usr/share/rocks/dpkg.query
71
72 EXPOSE 9273
73 ENTRYPOINT [ "/usr/bin/telegraf" ]

Subscribers

People subscribed via source and target branches

to all changes: