Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Docker build environments from creating root-owned artifacts #3354

Merged
merged 1 commit into from
Sep 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ UNIQUE:=$(shell date +%s)
GOVERSION=1.8.3
BINDATA_TARGETS=upup/models/bindata.go federation/model/bindata.go
BUILD=${GOPATH_1ST}/src/k8s.io/kops/.build
UID:=$(shell id -u)
GID:=$(shell id -g)

# See http://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile
MAKEDIR:=$(strip $(shell dirname "$(realpath $(lastword $(MAKEFILE_LIST)))"))
Expand Down Expand Up @@ -312,7 +314,7 @@ protokube-builder-image:

.PHONY: protokube-build-in-docker
protokube-build-in-docker: protokube-builder-image
docker run -t -e VERSION=${VERSION} -v `pwd`:/src protokube-builder /onbuild.sh
docker run -t -e VERSION=${VERSION} -e HOST_UID=${UID} -e HOST_GID=${GID} -v `pwd`:/src protokube-builder /onbuild.sh

.PHONY: protokube-image
protokube-image: protokube-build-in-docker
Expand Down Expand Up @@ -357,7 +359,7 @@ dns-controller-builder-image:

.PHONY: dns-controller-build-in-docker
dns-controller-build-in-docker: dns-controller-builder-image
docker run -t -v `pwd`:/src dns-controller-builder /onbuild.sh
docker run -t -e HOST_UID=${UID} -e HOST_GID=${GID} -v `pwd`:/src dns-controller-builder /onbuild.sh

.PHONY: dns-controller-image
dns-controller-image: dns-controller-build-in-docker
Expand Down
2 changes: 2 additions & 0 deletions images/dns-controller-builder/onbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ make dns-controller-gocode

mkdir -p /src/.build/artifacts/
cp /go/bin/dns-controller /src/.build/artifacts/

chown -R $HOST_UID:$HOST_GID /src/.build/artifacts
2 changes: 2 additions & 0 deletions images/protokube-builder/onbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ cp /go/bin/channels /src/.build/artifacts/
cd /src/.build/artifacts/
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.6.6/bin/linux/amd64/kubectl
chmod +x kubectl

chown -R $HOST_UID:$HOST_GID /src/.build/artifacts