Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

build / release makeover #766

Merged
merged 8 commits into from
Jun 14, 2019
Merged

build / release makeover #766

merged 8 commits into from
Jun 14, 2019

Conversation

krancour
Copy link
Contributor

By request from @jeremyrickard

Highlights:

  • Tracks vendored code (it's a modest 36 MB or so)
  • All dev tasks (tests, lint checks, etc) occur within a consistent, containerized environment
  • Multi-stage image builds
  • DinD image builds (don't require the host's docker socket to be mounted into containers)

cc @vdice

krancour added 3 commits June 10, 2019 18:18
Signed-off-by: Kent Rancourt <kent.rancourt@microsoft.com>
Signed-off-by: Kent Rancourt <kent.rancourt@microsoft.com>
Signed-off-by: Kent Rancourt <kent.rancourt@microsoft.com>
@bacongobbler
Copy link
Contributor

Isn't the purpose of a lockfile to pin dependencies at particular versions which can rebuild the vendor tree? I'm not following why the vendor directory needs to be checked into source control.

You need:
* A working Go 1.11.4 (or later) environment
Copy link
Contributor

Choose a reason for hiding this comment

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

If I run make build-all-bins without go in the path, the command fails with:

bash -c "LDFLAGS=\"-w -s -X github.com/deislabs/duffle/pkg/version.Version=c6a43ae\" scripts/build.sh"
building linux-amd64
scripts/build.sh: line 11: go: command not found
make: *** [build-all-bins] Error 127

So it seems that go is still needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You may have caught a mistake here. Will look.

Copy link
Contributor

@glyn glyn left a comment

Choose a reason for hiding this comment

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

I love not having to make bootstrap any more. The vendor/ directory will also insulate us from various network issues.

I'd like a quick/memorable way to make bin/duffle on macOS or linux.

It seems that Go is still needed, which is fine by me.

I'm not sure that building the docker image should be part of build, but that's fine so long as there are alternatives which can avoid it.

@krancour
Copy link
Contributor Author

I'd like a quick/memorable way to make bin/duffle on macOS or linux.

See doc changes. There is a way, but perhaps not adequately quick or memorable. I would be happy to add a few OS-specific convenience targets.

Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

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

LGTM for the build and vendoring part (not enough confident on brigade.js to review it properly...)

About versioning the vendoring, I don't have strong opinion about that, even if I prefer having everything versioned (easier to review/backtrack changes while bumping dependencies, safer if any dependency closes it's github account), but both options are fine with me.

Dockerfile Show resolved Hide resolved
@krancour
Copy link
Contributor Author

Isn't the purpose of a lockfile to pin dependencies at particular versions which can rebuild the vendor tree? I'm not following why the vendor directory needs to be checked into source control.

This is a classic debate and from what I have observed, dep users have mostly been erring on the side of tracking vendored code for some time now. You are absolutely correct that the .lock for enables a dependency tree to be rebuilt... as long as no one has deleted any library from github...

Beyond that, when vendor code isn't tracked, there's a need for some additional dependency resolution step (e.g. make bootstrap) to be run. For good measure, that should be run every time you check out a given branch, else you're potentially building with the wrong dependencies. So tracking vendored code has the advantage of being a little more foolproof in terms of the moment anyone clones the repo or checks out a branch, they already have the exact desired dependencies and are ready to build or test with no further adieu.

@glyn
Copy link
Contributor

glyn commented Jun 11, 2019

I'd like a quick/memorable way to make bin/duffle on macOS or linux.

See doc changes. There is a way, but perhaps not adequately quick or memorable. I would be happy to add a few OS-specific convenience targets.

That would be really helpful. I'd like something like make duffle or make darwin to produce bin/duffle (without any os/arch naming).

Makefile Outdated

.PHONY: build-all-bins
build-all-bins:
$(GO_DOCKER_CMD) bash -c "LDFLAGS=\"$(LDFLAGS)\" scripts/build.sh"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep... there a mistake on this line. The prefix here should just be DOCKER_CMD. GO_DOCKER_CMD is some copy/pasta and is always undefined and @glyn, this is why you were still needing Go on your path. I will fix this as soon as I get to a proper keyboard.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep... there a mistake on this line. The prefix here should just be DOCKER_CMD. GO_DOCKER_CMD is some copy/pasta and is always undefined and @glyn, this is why you were still needing Go on your path. I will fix this as soon as I get to a proper keyboard.

Thanks. But actually I like being able to do a "local" (i.e. non-docker) build using my Go tooling, so please can we preserve that, at least when just building bin/duffle for the current OS?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can opt out of it with SKIP_DOCKER=true.

krancour added 2 commits June 11, 2019 10:01
Signed-off-by: Kent Rancourt <kent.rancourt@microsoft.com>
… choosing

Signed-off-by: Kent Rancourt <kent.rancourt@microsoft.com>
@krancour
Copy link
Contributor Author

That would be really helpful. I'd like something like make duffle or make darwin to produce bin/duffle (without any os/arch naming).

@glyn I added a build-% target. You can build for your OS of choice with make build-<OS>. It assumes amd64 as the architecture.

without any os/arch naming

That makes me uneasy. The same build script that produces binaries on-demand for you also produces deployable artifacts in our pipeline. I think it's best if those artifacts are named unambiguously. This being said...

Elsewhere we discussed make install going away and I suggested creating a symlink instead. If you do so, there's no inconvenience to binaries having OS and architecture embedded in their name.

Does that seem ok?

@glyn
Copy link
Contributor

glyn commented Jun 11, 2019

That would be really helpful. I'd like something like make duffle or make darwin to produce bin/duffle (without any os/arch naming).

@glyn I added a build-% target. You can build for your OS of choice with make build-<OS>. It assumes amd64 as the architecture.

without any os/arch naming

That makes me uneasy. The same build script that produces binaries on-demand for you also produces deployable artifacts in our pipeline. I think it's best if those artifacts are named unambiguously. This being said...

Elsewhere we discussed make install going away and I suggested creating a symlink instead. If you do so, there's no inconvenience to binaries having OS and architecture embedded in their name.

Does that seem ok?

Yes. I can use a symlink duffle -> duffle-darwin-amd64.

@glyn
Copy link
Contributor

glyn commented Jun 11, 2019

I re-tested and SKIP_DOCKER=true make build-darwin works as expected as does make build-darwin. I wonder if you would mind documenting this in the developer's guide, for posterity?

Copy link
Contributor

@glyn glyn left a comment

Choose a reason for hiding this comment

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

Looks great now. Ideally, I'd like make duffle-darwin et al. described in the developer's guide, for posterity.

@krancour
Copy link
Contributor Author

Looks great now. Ideally, I'd like make duffle-darwin et al. described in the developer's guide, for posterity.

Yes. I will add that.

Copy link
Member

@vdice vdice left a comment

Choose a reason for hiding this comment

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

I'll leave the rest of the CI changes up to the interested parties who'll more actively interact w/ them, but otherwise all looks good to me. One minor comment on the brigade.js update...

brigade.js Outdated Show resolved Hide resolved
krancour added 2 commits June 11, 2019 13:44
Signed-off-by: Kent Rancourt <kent.rancourt@microsoft.com>
Signed-off-by: Kent Rancourt <kent.rancourt@microsoft.com>
@radu-matei
Copy link
Member

radu-matei commented Jun 12, 2019

Just tested on Windows:

PS C:\projects\go\src\github.com\deislabs\duffle> $env:SKIP_DOCKER
true
PS C:\projects\go\src\github.com\deislabs\duffle> make -f .\Makefile build
bash -c "LDFLAGS=\"-w -s -X github.com/deislabs/duffle/pkg/version.Version=de5062b\" scripts/build.sh"
building Windows_NT-amd64
cmd/go: unsupported GOOS/GOARCH pair Windows_NT/amd64
make: *** [build-all-bins] Error 2

Of course, this assumes WSL is configured on the machine; or requires the build to use Docker, none of which should be requirements for a simple go build.

@krancour
Copy link
Contributor Author

krancour commented Jun 12, 2019

@radu-matei lemme look at that. This is really odd. I'm not sure how Windows_NT got set as.the OS here. Do you have an existing env var by that name?

@krancour
Copy link
Contributor Author

Ok. Apparently the OS environment variable (which I am using) is pre-defined as Windows_NT on Windows (but not in WSL). So, if not executing within a container, in a place where I expected OS to either be a valid OS for Go cross-compiling or be undefined, it is neither of those things. I can fix this.

@krancour krancour changed the title build / release makeover WIP: build / release makeover Jun 12, 2019
Signed-off-by: Kent Rancourt <kent.rancourt@microsoft.com>
@krancour krancour changed the title WIP: build / release makeover build / release makeover Jun 12, 2019
@krancour
Copy link
Contributor Author

@radu-matei the latest issue you reported should be fixed by the latest commit.

Copy link
Member

@jeremyrickard jeremyrickard left a comment

Choose a reason for hiding this comment

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

LGTM

@technosophos
Copy link
Member

This currently has 4 LGTMs by core maintainers, so I am merging.

@technosophos technosophos merged commit bf4df3a into cnabio:master Jun 14, 2019
@krancour krancour deleted the build-release-makeover branch June 16, 2019 22:49
st3v added a commit to st3v/duffle that referenced this pull request Oct 21, 2019
PR cnabio#766 changed env vars to GOOS and GOARCH but forgot to update docs
st3v added a commit to st3v/duffle that referenced this pull request Nov 8, 2019
PR cnabio#766 changed env vars to GOOS and GOARCH but forgot to update docs

Signed-off-by: Stev Witzel <switzel@pivotal.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants