Skip to content

Commit 4e4d99b

Browse files
committed
dockerfile: install bats from source
Signed-off-by: CrazyMax <[email protected]>
1 parent 32b3295 commit 4e4d99b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/Dockerfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
ARG TEST_BASE_TYPE=alpine
55
ARG TEST_BASE_IMAGE=${TEST_BASE_TYPE}
66
ARG TEST_WITH_DARWIN=false
7+
ARG BATS_VERSION=v1.8.2
78

89
# build prepares the sources
910
FROM --platform=$BUILDPLATFORM alpine AS build
@@ -17,12 +18,17 @@ RUN ln -s xx-cc /out/xx-clang && \
1718
FROM scratch AS xx
1819
COPY --from=build /out/ /usr/bin/
1920

21+
FROM scratch AS bats-src
22+
ARG BATS_VERSION
23+
WORKDIR /opt/bats
24+
ADD "https://github.com/bats-core/bats-core.git#$BATS_VERSION" .
25+
2026
FROM --platform=$BUILDPLATFORM tonistiigi/bats-assert AS bats-assert
2127

2228
FROM ${TEST_BASE_IMAGE} AS test-base-alpine
2329
RUN --mount=type=cache,target=/pkg-cache \
2430
ln -s /pkg-cache /etc/apk/cache && \
25-
apk add bats vim
31+
apk add bash vim
2632
WORKDIR /work
2733

2834
FROM ${TEST_BASE_IMAGE} AS test-base-debian
@@ -31,7 +37,7 @@ RUN --mount=type=cache,target=/pkg-cache \
3137
ln -s /pkg-cache /var/cache/apt/archives && \
3238
rm /etc/apt/apt.conf.d/docker-clean && \
3339
echo 'Binary::apt::APT::Keep-Downloaded-Packages "1";' > /etc/apt/apt.conf.d/keep-downloads && \
34-
apt update && apt install --no-install-recommends -y bats vim
40+
apt update && apt install --no-install-recommends -y bash vim
3541
WORKDIR /work
3642

3743
FROM ${TEST_BASE_IMAGE} AS test-base-rhel
@@ -56,15 +62,17 @@ if ! yum install -y epel-release; then
5662
esac
5763
fi
5864
if command -v dnf >/dev/null 2>/dev/null; then
59-
dnf install -y bats vim
65+
dnf install -y bash vim
6066
else
61-
yum install -y bats vim
67+
yum install -y bash vim
6268
fi
6369
EOT
6470
WORKDIR /work
6571

6672
FROM test-base-${TEST_BASE_TYPE} AS test-base
6773
ADD --chmod=755 https://raw.githubusercontent.com/fsaintjacques/semver-tool/3.4.0/src/semver /usr/bin/semver
74+
COPY --from=bats-src /opt/bats /opt/bats
75+
RUN /opt/bats/install.sh /usr && bats --version
6876
COPY --from=bats-assert . .
6977
COPY --from=xx / /
7078

0 commit comments

Comments
 (0)