Skip to content

Dockerfile, circleci: update protoc to 3.6.1, simplify install#2756

Merged
dperny merged 1 commit intomoby:masterfrom
kolyshkin:no-io
Oct 4, 2018
Merged

Dockerfile, circleci: update protoc to 3.6.1, simplify install#2756
dperny merged 1 commit intomoby:masterfrom
kolyshkin:no-io

Conversation

@kolyshkin
Copy link
Copy Markdown
Contributor

Use unzip options to unpack directly to /usr/local/{include,bin},
to avoid unnecessary I/O.

Unfortunately unzip does not support unpacking from a pipe (due
to a limitation of .zip format -- the index is at EOF) so we still
have to save the .zip to disk, read it back, and remove. If they
could only provide tarballs... sigh

// cc @wk8 @anshulpundir

Comment thread Dockerfile Outdated
&& cd .. && rm -rf $PROTOC_TMP_DIR
RUN curl --silent --show-error --location --output protoc.zip \
https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip \
&& unzip protoc.zip -x readme.txt -d /usr/local \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda preferred the explicit mvs above, since it at least ensured we didn't copy whatever was in the archive, but only some files we cared about. IMO that outweighs whatever I/O we waste with the current version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing else in there (except for the readme.txt which we skip):

Archive:  protoc.zip
   creating: /usr/local/include/google/
   creating: /usr/local/include/google/protobuf/
  inflating: /usr/local/include/google/protobuf/struct.proto  
  inflating: /usr/local/include/google/protobuf/type.proto  
  inflating: /usr/local/include/google/protobuf/descriptor.proto  
  inflating: /usr/local/include/google/protobuf/api.proto  
  inflating: /usr/local/include/google/protobuf/empty.proto  
   creating: /usr/local/include/google/protobuf/compiler/
  inflating: /usr/local/include/google/protobuf/compiler/plugin.proto  
  inflating: /usr/local/include/google/protobuf/any.proto  
  inflating: /usr/local/include/google/protobuf/field_mask.proto  
  inflating: /usr/local/include/google/protobuf/wrappers.proto  
  inflating: /usr/local/include/google/protobuf/timestamp.proto  
  inflating: /usr/local/include/google/protobuf/duration.proto  
  inflating: /usr/local/include/google/protobuf/source_context.proto  
  inflating: /usr/local/bin/protoc  

I have also rechecked it with a latest version, 3.6.1:

Archive:  protoc.zip
   creating: /usr/local/include/google/
   creating: /usr/local/include/google/protobuf/
  inflating: /usr/local/include/google/protobuf/wrappers.proto  
  inflating: /usr/local/include/google/protobuf/field_mask.proto  
  inflating: /usr/local/include/google/protobuf/api.proto  
  inflating: /usr/local/include/google/protobuf/struct.proto  
  inflating: /usr/local/include/google/protobuf/descriptor.proto  
  inflating: /usr/local/include/google/protobuf/timestamp.proto  
   creating: /usr/local/include/google/protobuf/compiler/
  inflating: /usr/local/include/google/protobuf/compiler/plugin.proto  
  inflating: /usr/local/include/google/protobuf/empty.proto  
  inflating: /usr/local/include/google/protobuf/any.proto  
  inflating: /usr/local/include/google/protobuf/source_context.proto  
  inflating: /usr/local/include/google/protobuf/type.proto  
  inflating: /usr/local/include/google/protobuf/duration.proto  
  inflating: /usr/local/bin/protoc   

I suppose the creators of this .zip file are taking care of what's in there 😆

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't mean there'll never be anything else :) Sure, it's unlikely, but then for such a small benefit, why bother?

That being said, I don't feel super strongly about this, so as long as @dperny is okay with it, why not!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kolyshkin actually looking at unzip's man page:

SYNOPSIS
       unzip [-Z] [-cflptTuvz[abjnoqsCDKLMUVWX$/:^]] file[.zip] [file(s) ...]  [-x xfile(s) ...] [-d exdir]
[...]
       [file(s)]
              An optional list of archive members to be processed, separated by spaces.  (VMS versions compiled with  VMSCLI
              defined  must  delimit  files with commas instead.  See -v in OPTIONS below.)  Regular expressions (wildcards)
              may be used to match multiple members; see above.  Again, be sure to quote expressions that would otherwise be
              expanded or modified by the operating system.

so let's white-list the bin and the includes instead of blacklisting the readme?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense @wk8; patch updated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the list is the same as before:

Archive:  protoc.zip
   creating: /usr/local/include/google/
   creating: /usr/local/include/google/protobuf/
  inflating: /usr/local/include/google/protobuf/wrappers.proto  
  inflating: /usr/local/include/google/protobuf/field_mask.proto  
  inflating: /usr/local/include/google/protobuf/api.proto  
  inflating: /usr/local/include/google/protobuf/struct.proto  
  inflating: /usr/local/include/google/protobuf/descriptor.proto  
  inflating: /usr/local/include/google/protobuf/timestamp.proto  
   creating: /usr/local/include/google/protobuf/compiler/
  inflating: /usr/local/include/google/protobuf/compiler/plugin.proto  
  inflating: /usr/local/include/google/protobuf/empty.proto  
  inflating: /usr/local/include/google/protobuf/any.proto  
  inflating: /usr/local/include/google/protobuf/source_context.proto  
  inflating: /usr/local/include/google/protobuf/type.proto  
  inflating: /usr/local/include/google/protobuf/duration.proto  
  inflating: /usr/local/bin/protoc

Comment thread Dockerfile Outdated
# download and install protoc binary and .proto files
RUN curl --silent --show-error --location --output protoc.zip \
https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip \
&& unzip -d /usr/local protoc.zip include/\* bin\/* \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: I'd restrict that to bin/protoc, but feel free to ignore :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, it is actually better to use /usr/local folder same way than it is on CircleCI config.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd restrict that to bin/protoc

I can imagine some future version of protoc which calls another binary bundled in the same zip, let's say protoc-helper, and would not work without it, leaving a cryptic message, let's say execve: no such file or directory. With that in mind, I'd rather leave bin/\* in there.

Oh and I just spotted a bug here: it was bin\/* but should be bin/\*. Fixed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@olljanat
Copy link
Copy Markdown
Contributor

@kolyshkin This sounds good idea and especially migrate to Protobuf 3.6.1 as 3.5.0 version does not work anymore.

I did cherry-pick you commit to #2758 but I also needed to do same modifications to CircleCI config config to make it working. So can you include olljanat@7f8d217 to this PR?

@kolyshkin
Copy link
Copy Markdown
Contributor Author

So can you include olljanat/swarmkit@7f8d217 to this PR?

Right, I should have made changes to circleci config as well. Commit updated.

For the time being I omitted the nasty chmod 777, let's see if it will work without it (I guess that depends on umask setting in circleci environment)...

@kolyshkin kolyshkin force-pushed the no-io branch 4 times, most recently from bcf4bbc to e6d714f Compare October 2, 2018 00:39
@kolyshkin kolyshkin changed the title Dockerfile: simplify procobuf install Dockerfile, circleci: simplify protoc install Oct 2, 2018
@kolyshkin kolyshkin changed the title Dockerfile, circleci: simplify protoc install Dockerfile, circleci: update protoc to 3.6.1, simplify install Oct 2, 2018
@olljanat
Copy link
Copy Markdown
Contributor

olljanat commented Oct 2, 2018

@dperny can you check this one so I can drop Protoc update from my PR ( #2758 ) ?

Build looks failing but it look like that it have been issue on build server, not caused by this change so most probably it will work after rebuild.

@olljanat
Copy link
Copy Markdown
Contributor

olljanat commented Oct 4, 2018

@kolyshkin can you change example commit text little bit and push it here so it will trigger build running again.

@olljanat olljanat mentioned this pull request Oct 4, 2018
Comment thread Dockerfile
RUN curl --silent --show-error --location --output protoc.zip \
https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip \
&& unzip -d /usr/local protoc.zip include/\* bin/\* \
&& rm -f protoc.zip
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably this could be put into an install_protoc script that could then be called both by this Dockerfile and Circle

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree; maybe put it to direct.mk?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only problem is I'm waiting for #2750 to be merged first as it modifies Makefiles and I'd like to avoid rebasing )

Copy link
Copy Markdown
Contributor

@wk8 wk8 Oct 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on both accounts, reviewing 2750!

While at it, let's simplify installation

Use unzip options to unpack directly to /usr/local/{include,bin},
to avoid unnecessary I/O.

Unfortunately unzip does not support unpacking from a pipe (due
to a limitation of .zip format -- the index is at EOF) so we still
have to save the .zip to disk, read it back, and remove. If they
could only provide tarballs... *sigh*

[v2: update circleci config as well]
[v3: add chmod a+r to circleci]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Copy Markdown
Contributor Author

can you change example commit text little bit and push it here so it will trigger build running again.

done

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 4, 2018

Codecov Report

Merging #2756 into master will increase coverage by 0.1%.
The diff coverage is n/a.

@@            Coverage Diff            @@
##           master    #2756     +/-   ##
=========================================
+ Coverage   61.66%   61.77%   +0.1%     
=========================================
  Files         134      134             
  Lines       21890    21890             
=========================================
+ Hits        13499    13523     +24     
+ Misses       6932     6908     -24     
  Partials     1459     1459

@dperny
Copy link
Copy Markdown
Collaborator

dperny commented Oct 4, 2018

yeah LGTM, :shipit:

@dperny dperny merged commit 01966d4 into moby:master Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants