Skip to content

Commit a5a7714

Browse files
Merge pull request #1055 from adambkaplan/release-vol-mount
Use volume mount in release build
2 parents 8fdb399 + af408da commit a5a7714

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
.vscode/
66
cmd/s2i/debug
77
*~
8+
9+
# Version definition file used in release build
10+
sti-version-defs

Diff for: hack/build-release.sh

+7-14
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
set -o errexit
77
set -o nounset
88
set -o pipefail
9+
set -e
910

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

25-
context="${S2I_ROOT}/_output/buildenv-context"
26-
2726
# Clean existing output.
2827
rm -rf "${S2I_LOCAL_RELEASEPATH}"
29-
rm -rf "${context}"
30-
mkdir -p "${context}"
3128
mkdir -p "${S2I_LOCAL_RELEASEPATH}"
3229

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

3835
echo "++ Building release ${S2I_GIT_VERSION}"
3936

40-
# Create the input archive.
41-
git archive --format=tar -o "${context}/archive.tar" "${S2I_GIT_COMMIT}"
42-
tar -rf "${context}/archive.tar" -C "${context}" sti-version-defs
43-
gzip -f "${context}/archive.tar"
44-
4537
# Perform the build and release in podman or docker.
46-
cat "${context}/archive.tar.gz" | $buildCmd run -i --cidfile="${context}/cid" -e RELEASE_LDFLAGS="-w -s" openshift/sti-release
47-
$buildCmd cp $(cat ${context}/cid):/go/src/github.com/openshift/source-to-image/_output/local/releases "${S2I_OUTPUT}"
38+
$buildCmd run --rm -it -e RELEASE_LDFLAGS="-w -s" \
39+
-v "${S2I_ROOT}":/go/src/github.com/openshift/source-to-image:z \
40+
openshift/sti-release
4841
echo "${S2I_GIT_COMMIT}" > "${S2I_LOCAL_RELEASEPATH}/.commit"
4942

50-
ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"
43+
ret=$?; ENDTIME=$(date +%s); echo "$0 took $((ENDTIME - STARTTIME)) seconds"; exit "$ret"

Diff for: images/release/Dockerfile

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin
1515
RUN yum install -y gcc zip && \
1616
yum clean all && \
1717
curl https://storage.googleapis.com/golang/go$VERSION.linux-amd64.tar.gz | tar -C /usr/local -xzf - && \
18-
touch /sti-build-image
18+
touch /sti-build-image && \
19+
mkdir -p /go/src/github.com/openshift/source-to-image
1920

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

0 commit comments

Comments
 (0)