Skip to content

Commit

Permalink
Merge pull request #1055 from adambkaplan/release-vol-mount
Browse files Browse the repository at this point in the history
Use volume mount in release build
  • Loading branch information
openshift-merge-robot committed Oct 9, 2020
2 parents 8fdb399 + af408da commit a5a7714
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
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"]

0 comments on commit a5a7714

Please sign in to comment.