Skip to content

Commit 34c7af9

Browse files
committed
Fix for buildah
Signed-off-by: Jose A. Rivera <jarrpa@redhat.com>
1 parent fde8c08 commit 34c7af9

File tree

3 files changed

+20
-41
lines changed

3 files changed

+20
-41
lines changed

build.sh

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ DRIVER="${DRIVER:-glusterfs-csi-driver}"
88
# Set which docker repo to tag
99
REPO="${REPO:-gluster/}"
1010

11-
# Base image to use for final container images
12-
FINAL_BASE="${FINAL_BASE:-centos:7.5.1804}"
13-
1411
# Allow overriding default docker command
15-
DOCKER_CMD=${DOCKER_CMD:-docker}
12+
RUNTIME_CMD=${RUNTIME_CMD:-docker}
13+
14+
build="build"
15+
if [[ "${RUNTIME_CMD}" == "buildah" ]]; then
16+
build="bud"
17+
fi
1618

1719
# Allow disabling tests during build
1820
RUN_TESTS=${RUN_TESTS:-1}
1921

20-
# Cleanup build context when done
21-
RM_BUILD=${RM_BUILD:-1}
22-
2322
VERSION="$(git describe --dirty --always --tags | sed 's/-/./2' | sed 's/-/./2')"
2423
BUILDDATE="$(date -u '+%Y-%m-%dT%H:%M:%S.%NZ')"
2524

@@ -32,27 +31,16 @@ build_args+=( --build-arg "RUN_TESTS=$RUN_TESTS" )
3231
build_args+=( --build-arg "GO_DEP_VERSION=$GO_DEP_VERSION" )
3332
build_args+=( --build-arg "GO_METALINTER_VERSION=$GO_METALINTER_VERSION" )
3433
build_args+=( --build-arg "GO_METALINTER_THREADS=$GO_METALINTER_THREADS" )
35-
build_args+=( --build-arg "FINAL_BASE=$FINAL_BASE" )
3634
build_args+=( --build-arg "version=$VERSION" )
3735
build_args+=( --build-arg "builddate=$BUILDDATE" )
3836

3937
# Print Docker version
40-
echo "=== Docker Version ==="
41-
$DOCKER_CMD version
38+
echo "=== $RUNTIME_CMD version ==="
39+
$RUNTIME_CMD version
4240

43-
# Run container build
44-
$DOCKER_CMD build \
45-
-t glusterfs-csi-driver-build \
46-
--target build \
47-
"${build_args[@]}" \
48-
-f pkg/glusterfs/Dockerfile \
49-
. \
50-
|| exit 1
51-
52-
#-- Build final container
53-
$DOCKER_CMD build \
41+
#-- Build container
42+
$RUNTIME_CMD $build \
5443
-t "${REPO}${DRIVER}" \
55-
--target driver \
5644
"${build_args[@]}" \
5745
-f pkg/glusterfs/Dockerfile \
5846
. \
@@ -61,10 +49,6 @@ $DOCKER_CMD build \
6149
# If running tests, extract profile data
6250
if [ "$RUN_TESTS" -ne 0 ]; then
6351
rm -f profile.cov
64-
$DOCKER_CMD run glusterfs-csi-driver-build \
65-
cat /profile.cov > profile.cov
66-
fi
67-
68-
if [ "$RM_BUILD" -ne 0 ]; then
69-
$DOCKER_CMD rmi -f glusterfs-csi-driver-build
52+
$RUNTIME_CMD run --entrypoint cat "${REPO}${DRIVER}" \
53+
/profile.cov > profile.cov
7054
fi

pkg/glusterfs/Dockerfile

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212

13-
# The base image to use for the final images
14-
ARG FINAL_BASE=centos
15-
1613
#-- Create build environment
1714

18-
FROM openshift/origin-release:golang-1.10 AS make_env
15+
FROM docker.io/openshift/origin-release:golang-1.10 as build
1916

2017
ENV GOPATH="/go/" \
2118
SRCDIR="/go/src/github.com/gluster/gluster-csi-driver/" \
@@ -42,28 +39,26 @@ COPY scripts/ "${SCRIPTSDIR}"
4239

4340
#-- Test phase
4441

45-
FROM make_env AS test
4642
ARG RUN_TESTS=1
4743
ARG GO_METALINTER_THREADS=1
4844
ENV TEST_COVERAGE=stdout \
49-
GO_COVER_OUT=/profile.cov
45+
GO_COVER_DIR=/build/
5046

47+
RUN mkdir /build
5148
RUN [ $RUN_TESTS -eq 0 ] || ${SCRIPTSDIR}/lint-go.sh
5249
RUN [ $RUN_TESTS -eq 0 ] || ${SCRIPTSDIR}/test-go.sh
5350

5451
#-- Build phase
5552

56-
FROM test AS build
57-
5853
# Build executable
59-
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags '-extldflags "-static"' -o /glusterfs-csi-driver cmd/glusterfs/main.go
54+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags '-extldflags "-static"' -o /build/glusterfs-csi-driver cmd/glusterfs/main.go
6055

6156
# Ensure the binary is statically linked
62-
RUN ldd /glusterfs-csi-driver | grep -q "not a dynamic executable"
57+
RUN ldd /build/glusterfs-csi-driver | grep -q "not a dynamic executable"
6358

6459
#-- Final container
6560

66-
FROM ${FINAL_BASE} AS driver
61+
FROM docker.io/centos:7.5.1804 as final
6762

6863
# Install dependencies
6964
RUN yum -y install centos-release-gluster && \
@@ -73,7 +68,7 @@ RUN yum -y install centos-release-gluster && \
7368
rpm -qa | grep gluster | tee /gluster-rpm-versions.txt
7469

7570
# Copy glusterfs-csi-driver from build phase
76-
COPY --from=build /glusterfs-csi-driver /glusterfs-csi-driver
71+
COPY --from=build /build /
7772

7873
# The version of the driver (git describe --dirty --always --tags | sed 's/-/./2' | sed 's/-/./2')
7974
ARG version="(unknown)"

scripts/test-go.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
GOPACKAGES="$(go list ./... | grep -v vendor | grep -v e2e)"
4-
COVERFILE="${GO_COVER_OUT:-profile.cov}"
4+
COVERFILE="${GO_COVER_DIR}profile.cov"
55

66
# no special options, exec to go test w/ all pkgs
77
if [[ ${TEST_EXITFIRST} != "yes" && -z ${TEST_COVERAGE} ]]; then

0 commit comments

Comments
 (0)