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

Use volume mount in release build #1055

Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
.vscode/
cmd/s2i/debug
*~

# Version definition file used in release build
sti-version-defs
21 changes: 7 additions & 14 deletions hack/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
set -o errexit
set -o nounset
set -o pipefail
set -e

STARTTIME=$(date +%s)
S2I_ROOT=$(dirname "${BASH_SOURCE}")/..
S2I_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${S2I_ROOT}/hack/common.sh"
source "${S2I_ROOT}/hack/util.sh"
s2i::log::install_errexit
Expand All @@ -22,29 +23,21 @@ cd "${S2I_ROOT}"
echo "++ Building openshift/sti-release"
$buildCmd build -q --tag openshift/sti-release "${S2I_ROOT}/images/release"

context="${S2I_ROOT}/_output/buildenv-context"

# Clean existing output.
rm -rf "${S2I_LOCAL_RELEASEPATH}"
rm -rf "${context}"
mkdir -p "${context}"
mkdir -p "${S2I_LOCAL_RELEASEPATH}"

# Generate version definitions.
# You can commit a specific version by specifying S2I_GIT_COMMIT="" prior to build
s2i::build::get_version_vars
s2i::build::save_version_vars "${context}/sti-version-defs"
s2i::build::save_version_vars "${S2I_ROOT}/sti-version-defs"

echo "++ Building release ${S2I_GIT_VERSION}"

# Create the input archive.
git archive --format=tar -o "${context}/archive.tar" "${S2I_GIT_COMMIT}"
tar -rf "${context}/archive.tar" -C "${context}" sti-version-defs
gzip -f "${context}/archive.tar"

# Perform the build and release in podman or docker.
cat "${context}/archive.tar.gz" | $buildCmd run -i --cidfile="${context}/cid" -e RELEASE_LDFLAGS="-w -s" openshift/sti-release
$buildCmd cp $(cat ${context}/cid):/go/src/github.com/openshift/source-to-image/_output/local/releases "${S2I_OUTPUT}"
$buildCmd run --rm -it -e RELEASE_LDFLAGS="-w -s" \
-v "${S2I_ROOT}":/go/src/github.com/openshift/source-to-image:z \
openshift/sti-release
echo "${S2I_GIT_COMMIT}" > "${S2I_LOCAL_RELEASEPATH}/.commit"

ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"
ret=$?; ENDTIME=$(date +%s); echo "$0 took $((ENDTIME - STARTTIME)) seconds"; exit "$ret"
9 changes: 5 additions & 4 deletions images/release/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin
RUN yum install -y gcc zip && \
yum clean all && \
curl https://storage.googleapis.com/golang/go$VERSION.linux-amd64.tar.gz | tar -C /usr/local -xzf - && \
touch /sti-build-image
touch /sti-build-image && \
mkdir -p /go/src/github.com/openshift/source-to-image

WORKDIR /go/src/github.com/openshift/source-to-image

# Expect a tar with the source of STI (and /sti-version-defs in the root)
CMD tar mxzf - && hack/build-cross.sh
VOLUME ["/go/src/github.com/openshift/source-to-image"]
# Expect source to be mounted in
CMD ["./hack/build-cross.sh"]