Enhance Dockerfile for local building by chrisplo · Pull Request #1002 · contiv/netplugin · GitHub
Skip to content

Enhance Dockerfile for local building#1002

Merged
chrisplo merged 5 commits into
contiv:masterfrom
chrisplo:dockerfile_compile_update
Oct 13, 2017
Merged

Enhance Dockerfile for local building#1002
chrisplo merged 5 commits into
contiv:masterfrom
chrisplo:dockerfile_compile_update

Conversation

@chrisplo

@chrisplo chrisplo commented Oct 10, 2017

Copy link
Copy Markdown
Contributor

Added a caching layer in the docker build for compiling all of the
vendor dependencies, drops compilation time to about 15s

Added support in Dockerfile for passing BUILD_VERSION and
NIGHTLY_RELEASE to build.sh

Add compile-with-docker target

Split out how we get the git commit SHA so it's reusable for docker
image tag

Added a caching layer in the docker build for compiling all of the
vendor dependencies, drops compilation time to about 15s

Added support in Dockerfile for passing BUILD_VERSION and USE_RELEASE
to build.sh

Add compile-with-docker target

Split out how we get the git commit SHA so it's reusable for docker
image tag
@chrisplo

Copy link
Copy Markdown
Contributor Author

@chrisplo

Copy link
Copy Markdown
Contributor Author

make build was successfull as well

Comment thread Dockerfile Outdated
CMD ["--help"]

COPY ./ /go/src/github.com/contiv/netplugin/
# build the vendor dependencies

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.

Since it's not obvious (apparently lol) why this is being done manually as a separate step, could you update the comment here to explain that this is for caching purposes because vendored code takes a long time to compile?

@chrisplo

Copy link
Copy Markdown
Contributor Author

I pulled a compile target last minute as thought wasn't needed, need to restore, will add comments as well

@chrisplo

chrisplo commented Oct 10, 2017

Copy link
Copy Markdown
Contributor Author

rechecked make compile-with-docker and

$ docker run --entrypoint ls netplugin:devBuild-c18b3301-unsupported /etc/bash_completion.d/netctl
/etc/bash_completion.d/netctl

@chrisplo

Copy link
Copy Markdown
Contributor Author

build PR

@dseevr

dseevr commented Oct 12, 2017

Copy link
Copy Markdown
Contributor

Now that #999 is merged, you can remove that grep -v and such

Comment thread scripts/getGitCommit.sh
@@ -0,0 +1,13 @@
#!/bin/bash

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.

Can we get a

set -euo pipefail

here? I think we should include it in every new script by default.

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.

good catch, thx

Comment thread scripts/getGitCommit.sh
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
GIT_COMMIT="$GIT_COMMIT-unsupported"
fi
echo $GIT_COMMIT

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.

Inconsistent indentation on lines 8 and 9 vs. 4-7

Check out shfmt if you want an easy way to automatically tidy up scripts. We use this on auth_proxy and install

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.

wth is are tabs doing in there :/

Comment thread Dockerfile
RUN GOPATH=/go/ \
BUILD_VERSION="${BUILD_VERSION}" \
USE_RELEASE="${USE_RELEASE}" \
make compile \

@gkvijay gkvijay Oct 12, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you are compiling netplugin as part of docker build then you should add atleast checks here. Otherwise, we may not catching errors. If the idea is to make a quick build knowing that there are no code changes (for releases), then can Dockerfile only compile vendor directory and build the container. User can decide to skip tests when running the make using docker exec command

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 have checks for docker based build as a backlog item but this isn't replacing other ways to build so it's not required (yet), and this PR is long enough already.

I was planning to have a separate Dockerfile that does the checks after compile which I think matches development flow better and will be faster to iterate. Also, will allow choice as to when to run the checks based on which target is being run in the Makefile.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add the development Dockerfile here (root directory) and move the one with no checks to a release directory. Please take care of it in a later PR

@chrisplo

Copy link
Copy Markdown
Contributor Author

I will also check for changes due to PR1000 merging

@chrisplo chrisplo force-pushed the dockerfile_compile_update branch 2 times, most recently from 3766099 to 27a0a57 Compare October 12, 2017 18:55
go-winio is now safe to include in compile
strict bash checks and fix indents getGitCommit.sh
switch docker build from USE_RELEASE to NIGHTLY_BUILD
@chrisplo chrisplo force-pushed the dockerfile_compile_update branch from 27a0a57 to 1097d2a Compare October 12, 2017 18:57
@dseevr

dseevr commented Oct 12, 2017

Copy link
Copy Markdown
Contributor

build pr

@chrisplo

Copy link
Copy Markdown
Contributor Author

do you want me to pull apart the getGitCommit as separate PR @unclejack @dseevr ?

@dseevr

dseevr commented Oct 12, 2017

Copy link
Copy Markdown
Contributor

It's required for this PR to be merged and function so it seems fine to me as it is

@chrisplo

chrisplo commented Oct 12, 2017

Copy link
Copy Markdown
Contributor Author

when squash merging this please use the PR description as the commit msg (instead of the first commit msg)

Comment thread Makefile Outdated
docker build \
--build-arg NIGHTLY_RELEASE=${NIGHTLY_RELEASE} \
--build-arg BUILD_VERSION=${BUILD_VERSION} \
-t netplugin:$${BUILD_VERSION:-devBuild}-$$(./scripts/getGitCommit.sh) .

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.

devbuild not devBuild

@dseevr

dseevr commented Oct 12, 2017

Copy link
Copy Markdown
Contributor

build pr

@dseevr

dseevr commented Oct 13, 2017

Copy link
Copy Markdown
Contributor

@unclejack PTAL and merge if it looks good

Comment thread Dockerfile
RUN GOPATH=/go/ \
BUILD_VERSION="${BUILD_VERSION}" \
USE_RELEASE="${USE_RELEASE}" \
make compile \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add the development Dockerfile here (root directory) and move the one with no checks to a release directory. Please take care of it in a later PR

Comment thread Dockerfile
ARG BUILD_VERSION=""
ARG NIGHTLY_RELEASE=""

RUN GOPATH=/go/ \

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.

This Dockerfile should call make deps at some point to add the tools used to check if the source is fine to the image.

The executed command should include the checks target to run it before the build. This should reject code which doesn't meet the requirements.

Comment thread Makefile
# fully prepares code for pushing to branch, includes building binaries
run-build: deps checks clean compile

compile-with-docker:

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.

Could you set up these tasks like this, please?
host-compile-with-docker: -what we have in this target
compile-with-docker: - a wrapper which builds this in the Vagrant VM (e.g.: vagrant ssh netplugin-node1 -c 'bash -lc "source /etc/profile.d/envvar.sh && cd /opt/gopath/src/github.com/contiv/netplugin && make host-compile-with-docker"')

It should be possible to invoke these targets on the host and on the VMs.

@unclejack

Copy link
Copy Markdown
Contributor

@chrisplo: Can you get rid of the merge commit and integrate the changes into their corresponding commits, please?

@unclejack

Copy link
Copy Markdown
Contributor

@chrisplo chrisplo merged commit 5732e53 into contiv:master Oct 13, 2017
@chrisplo chrisplo deleted the dockerfile_compile_update branch October 27, 2017 00:41
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