Skip to content

Commit e3bb13a

Browse files
Reorganize the OpenShift builds into three stages
* Base image - based on CentOS 7 and are the core for other images * Release image - a Git cross-platform compile environment that isolates external dependencies * Origin and other dependent images * Add useLocalImages to custom pod deployer The release build generates a set of tar archives containing the binaries for each platform. The origin image uses the binary from the release, without the Git environment. The remaining platform images are based on the origin image and do no builds of their own.
1 parent ec27d44 commit e3bb13a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+945
-510
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
*.swp
88
.vimrc
99
.vagrant-openshift.json
10+
.DS_Store

Dockerfile

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1-
FROM google/golang
2-
MAINTAINER Jessica Forrester <[email protected]>
1+
#
2+
# This is the unofficial OpenShift Origin image for the DockerHub. It has as its
3+
# entrypoint the OpenShift all-in-one binary.
4+
#
5+
# See images/origin for the official release version of this image
6+
#
7+
# The standard name for this image is openshift/origin
8+
#
9+
FROM openshift/origin-base
10+
11+
RUN yum install -y golang && yum clean all
12+
13+
WORKDIR /go/src/github.com/openshift/origin
14+
ADD . /go/src/github.com/openshift/origin
15+
ENV GOPATH /go
16+
ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin
317

4-
WORKDIR /gopath/src/github.com/openshift/origin
5-
ADD . /gopath/src/github.com/openshift/origin
618
RUN go get github.com/openshift/origin && \
7-
hack/build-go.sh
19+
hack/build-go.sh && \
20+
cp _output/local/go/bin/* /usr/bin/
821

922
EXPOSE 8080
10-
ENTRYPOINT ["_output/go/bin/openshift"]
23+
ENTRYPOINT ["/usr/bin/openshift"]

HACKING.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
Hacking on OpenShift
22
====================
33

4+
## Building a Release
5+
6+
To build an OpenShift release you run the `hack/build-release.sh` script on a system with Docker, which
7+
will create a build environment image and then execute a cross platform Go build within it. The build
8+
output will be copied to `_output/releases` as a set of tars containing each version. It will also build
9+
the `openshift/origin-base` image which is the common parent image for all OpenShift Docker images.
10+
11+
$ hack/build-release.sh
12+
13+
Once the release has been built the official Docker images can be generated with `hack/build-images.sh`.
14+
The resulting images can then be pushed to a Docker registry.
15+
16+
$ hack/build-images.sh
17+
18+
Note: To build the base and release images, run:
19+
20+
$ hack/build-base-images.sh
21+
22+
423
## Test Suites
524

625
OpenShift uses three levels of testing - unit tests, integration test, and end-to-end tests (much

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ Once setup, you can:
2828

2929
2. Start an OpenShift all-in-one server (includes everything you need to try OpenShift)
3030

31-
$ _output/go/bin/openshift start
31+
$ _output/local/go/bin/openshift start
3232

3333
3. In another terminal window, switch to the directory and start an app:
3434

3535
$ cd $GOPATH/src/github.com/openshift/origin
36-
$ _output/go/bin/openshift kube create pods -c examples/hello-openshift/hello-pod.json
36+
$ _output/local/go/bin/openshift kube create pods -c examples/hello-openshift/hello-pod.json
3737

3838
Once that's done, open a browser on your machine and open [http://localhost:6061](http://localhost:6061); you should see a 'Welcome to OpenShift' message.
3939

hack/before-install-assets.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/bin/bash
22

3-
set -e
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
46

57
# If we are running inside of Travis then do not run the rest of this
68
# script unless we want to TEST_ASSETS
7-
if [[ "${TRAVIS}" == "true" && "${TEST_ASSETS}" == "false" ]]; then
9+
if [[ "${TRAVIS-}" == "true" && "${TEST_ASSETS-}" == "false" ]]; then
810
exit
911
fi
1012

hack/build-api-docs-image.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ set -o errexit
44
set -o nounset
55
set -o pipefail
66

7-
hackdir=$(CDPATH="" cd $(dirname $0); pwd)
7+
OS_ROOT=$(dirname "${BASH_SOURCE}")/..
8+
source "${OS_ROOT}/hack/common.sh"
89

9-
cd $hackdir/../api && docker build -t kubernetes/raml2html .
10+
cd "${OS_ROOT}/api"
11+
docker build -t kubernetes/raml2html .
1012
docker rm openshift3docgen &>/dev/null || :
1113
docker run --name=openshift3docgen kubernetes/raml2html
12-
docker cp openshift3docgen:/data/openshift3.html $hackdir/../api/
14+
docker cp openshift3docgen:/data/openshift3.html ${OS_ROOT}/api/
1315
docker rm openshift3docgen &>/dev/null || :

hack/build-assets.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
#!/bin/bash
22

3-
set -e
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
46

5-
hackdir=$(CDPATH="" cd $(dirname $0); pwd)
7+
OS_ROOT=$(dirname "${BASH_SOURCE}")/..
8+
source "${OS_ROOT}/hack/common.sh"
69

7-
pushd ${hackdir}/../assets > /dev/null
10+
pushd "${OS_ROOT}/assets" > /dev/null
811
bundle exec grunt build
912
popd > /dev/null
1013

11-
pushd ${hackdir}/../ > /dev/null
14+
pushd "${OS_ROOT}" > /dev/null
1215
Godeps/_workspace/bin/go-bindata -prefix "assets/dist" -pkg "assets" -o "pkg/assets/bindata.go" assets/dist/...
1316
popd > /dev/null

hack/build-base-images.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# This script builds the base and release images for use by the release build and image builds.
4+
#
5+
# Set OS_IMAGE_PUSH=true to push images to a registry
6+
#
7+
8+
set -o errexit
9+
set -o nounset
10+
set -o pipefail
11+
12+
OS_ROOT=$(dirname "${BASH_SOURCE}")/..
13+
source "${OS_ROOT}/hack/common.sh"
14+
15+
# Go to the top of the tree.
16+
cd "${OS_ROOT}"
17+
18+
# Build the images
19+
docker build --tag openshift/origin-base "${OS_ROOT}/images/base"
20+
docker build --tag openshift/origin-haproxy-router-base "${OS_ROOT}/images/router/haproxy-base"
21+
docker build --tag openshift/origin-release "${OS_ROOT}/images/release"

hack/build-cross.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# Build all cross compile targets and the base binaries
4+
5+
set -o errexit
6+
set -o nounset
7+
set -o pipefail
8+
9+
OS_ROOT=$(dirname "${BASH_SOURCE}")/..
10+
source "${OS_ROOT}/hack/common.sh"
11+
12+
OS_BUILD_PLATFORMS=("${OS_COMPILE_PLATFORMS[@]}")
13+
os::build::build_binaries "${OS_COMPILE_TARGETS[@]}"
14+
15+
OS_BUILD_PLATFORMS=("${OS_CROSS_COMPILE_PLATFORMS[@]}")
16+
os::build::build_binaries "${OS_CROSS_COMPILE_TARGETS[@]}"
17+
18+
OS_RELEASE_ARCHIVES="${OS_OUTPUT}/releases"
19+
os::build::place_bins

hack/build-go.sh

+4-23
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,8 @@ set -o errexit
66
set -o nounset
77
set -o pipefail
88

9-
hackdir=$(CDPATH="" cd $(dirname $0); pwd)
9+
OS_ROOT=$(dirname "${BASH_SOURCE}")/..
10+
source "${OS_ROOT}/hack/common.sh"
1011

11-
# Set the environment variables required by the build.
12-
. "${hackdir}/config-go.sh"
13-
14-
# Go to the top of the tree.
15-
cd "${OS_REPO_ROOT}"
16-
17-
if [[ $# == 0 ]]; then
18-
# Update $@ with the default list of targets to build.
19-
set -- cmd/openshift cmd/openshift-router cmd/openshift-deploy
20-
fi
21-
22-
binaries=()
23-
for arg; do
24-
binaries+=("${OS_GO_PACKAGE}/${arg}")
25-
done
26-
27-
build_tags=""
28-
if [[ ! -z "$OS_BUILD_TAGS" ]]; then
29-
build_tags="-tags \"$OS_BUILD_TAGS\""
30-
fi
31-
32-
go install $build_tags -ldflags "$(os::build::ldflags)" "${binaries[@]}"
12+
os::build::build_binaries "$@"
13+
os::build::place_bins

hack/build-images.sh

+45-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,56 @@
11
#!/bin/bash
22

3-
# This script builds all images locally (requires Docker)
3+
# This script builds all images locally except the base and release images,
4+
# which are handled by hack/build-base-images.sh.
45

56
set -o errexit
67
set -o nounset
78
set -o pipefail
89

9-
hackdir=$(CDPATH="" cd $(dirname $0); pwd)
10-
11-
# Set the environment variables required by the build.
12-
. "${hackdir}/config-go.sh"
10+
OS_ROOT=$(dirname "${BASH_SOURCE}")/..
11+
source "${OS_ROOT}/hack/common.sh"
1312

1413
# Go to the top of the tree.
15-
cd "${OS_REPO_ROOT}"
14+
cd "${OS_ROOT}"
15+
16+
# Get the latest Linux release
17+
if [[ ! -d _output/local/releases ]]; then
18+
echo "No release has been built. Run hack/build-release.sh"
19+
exit 1
20+
fi
21+
releases=$(find _output/local/releases/ -print | grep 'openshift-origin-.*-linux-' --color=never)
22+
if [[ $(echo $releases | wc -l) -ne 1 ]]; then
23+
echo "There must be exactly one Linux release tar in _output/local/releases"
24+
exit 1
25+
fi
26+
echo "Building images from ${releases}"
27+
28+
imagedir="_output/imagecontext"
29+
rm -rf "${imagedir}"
30+
mkdir -p "${imagedir}"
31+
tar xzf "${releases}" -C "${imagedir}"
32+
33+
# copy build artifacts to the appropriate locations
34+
cp -f "${imagedir}/openshift" images/origin/bin
35+
cp -f "${imagedir}/openshift-deploy" images/origin/bin
36+
cp -f "${imagedir}/openshift-router" images/origin/bin
37+
cp -f "${imagedir}/openshift-router" images/router/haproxy/bin
38+
39+
# build hello-openshift binary
40+
"${OS_ROOT}/hack/build-go.sh" examples/hello-openshift
1641

17-
# Fetch the version.
18-
version=$(os::build::gitcommit)
19-
kube_version=$(go run ${hackdir}/version.go ${hackdir}/../Godeps/Godeps.json github.com/GoogleCloudPlatform/kubernetes/pkg/api)
42+
# images that depend on openshift/origin-base
43+
echo "--- openshift/origin ---"
44+
docker build -t openshift/origin images/origin
45+
echo "--- openshift/origin-haproxy-router ---"
46+
docker build -t openshift/origin-haproxy-router images/router/haproxy
47+
echo "--- openshift/hello-openshift ---"
48+
docker build -t openshift/hello-openshift examples/hello-openshift
2049

21-
docker build -t openshift/base-builder images/builder/docker/base
22-
docker build -t openshift/docker-builder images/builder/docker/docker-builder
23-
docker build -t openshift/sti-builder images/builder/docker/sti-builder
24-
docker build -t openshift/hello-openshift examples/hello-openshift
50+
# images that depend on openshift/origin
51+
echo "--- openshift/origin-deployer ---"
52+
docker build -t openshift/origin-deployer images/deploy/customimage
53+
echo "--- openshift/origin-docker-builder ---"
54+
docker build -t openshift/origin-docker-builder images/builder/docker/docker-builder
55+
echo "--- openshift/origin-sti-builder ---"
56+
docker build -t openshift/origin-sti-builder images/builder/docker/sti-builder

hack/build-release.sh

+23-14
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,46 @@
11
#!/bin/bash
22

3-
# This script generates release zips into _output/releases
3+
# This script generates release zips into _output/releases. It requires the openshift/origin-release
4+
# image to be built prior to executing this command via hack/build-base-images.sh.
45

56
set -o errexit
67
set -o nounset
78
set -o pipefail
89

9-
hackdir=$(CDPATH="" cd $(dirname $0); pwd)
10-
11-
# Set the environment variables required by the build.
12-
. "${hackdir}/config-go.sh"
10+
OS_ROOT=$(dirname "${BASH_SOURCE}")/..
11+
source "${OS_ROOT}/hack/common.sh"
1312

1413
# Go to the top of the tree.
15-
cd "${OS_REPO_ROOT}"
14+
cd "${OS_ROOT}"
1615

17-
context="${OS_REPO_ROOT}/_output/buildenv-context"
16+
context="${OS_ROOT}/_output/buildenv-context"
1817

1918
# clean existing output
20-
rm -rf "${OS_REPO_ROOT}/_output/releases"
19+
rm -rf "${OS_ROOT}/_output/local/releases"
20+
rm -rf "${OS_ROOT}/_output/go/bin"
2121
rm -rf "${context}"
2222
mkdir -p "${context}"
23+
mkdir -p "${OS_ROOT}/_output/local"
2324

2425
# generate version definitions
25-
echo "export OS_VERSION=0.1" > "${context}/os-version-defs"
26-
echo "export OS_GITCOMMIT=\"$(os::build::gitcommit)\"" >> "${context}/os-version-defs"
27-
echo "export OS_LD_FLAGS=\"$(os::build::ldflags)\"" >> "${context}/os-version-defs"
26+
os::build::get_version_vars
27+
os::build::save_version_vars "${context}/os-version-defs"
2828

2929
# create the input archive
3030
git archive --format=tar -o "${context}/archive.tar" HEAD
3131
tar -rf "${context}/archive.tar" -C "${context}" os-version-defs
3232
gzip -f "${context}/archive.tar"
3333

3434
# build in the clean environment
35-
docker build --tag openshift-origin-buildenv "${OS_REPO_ROOT}/hack/buildenv"
36-
cat "${context}/archive.tar.gz" | docker run -i --cidfile="${context}/cid" openshift-origin-buildenv
37-
docker cp $(cat ${context}/cid):/go/src/github.com/openshift/origin/_output/releases "${OS_REPO_ROOT}/_output"
35+
cat "${context}/archive.tar.gz" | docker run -i --cidfile="${context}/cid" openshift/origin-release
36+
docker cp $(cat ${context}/cid):/go/src/github.com/openshift/origin/_output/local/releases "${OS_ROOT}/_output/local"
37+
38+
# copy the linux release back to the _output/go/bin dir
39+
releases=$(find _output/local/releases/ -print | grep 'openshift-origin-.*-linux-' --color=never)
40+
if [[ $(echo $releases | wc -l) -ne 1 ]]; then
41+
echo "There should be exactly one Linux release tar in _output/local/releases"
42+
exit 1
43+
fi
44+
bindir="_output/go/bin"
45+
mkdir -p "${bindir}"
46+
tar mxzf "${releases}" -C "${bindir}"

hack/buildenv/Dockerfile

-29
This file was deleted.

hack/buildenv/build.sh

-25
This file was deleted.

0 commit comments

Comments
 (0)