Skip to content

Commit 395c288

Browse files
committed
Bundle perf-test artefact in the Docker image
Push all Docker image building concerns into the Dockerfile. This ensures that it will always work, regardless of the host that builds the Docker image.
1 parent 82f8937 commit 395c288

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
FROM openjdk:8u181-jre-alpine3.8
22

3-
ARG perf_test_distribution
4-
RUN apk add --no-cache bash
5-
VOLUME /tmp
6-
COPY $perf_test_distribution/ /tmp/
7-
ENTRYPOINT ["/tmp/bin/runjava", "com.rabbitmq.perf.PerfTest"]
3+
ARG perf_test_version
4+
ENV URL=https://github.com/rabbitmq/rabbitmq-perf-test/releases/download/v$perf_test_version/rabbitmq-perf-test-$perf_test_version-bin.tar.gz
5+
6+
RUN apk add --no-cache bash curl ca-certificates
7+
8+
# Fail fast if URL is invalid
9+
RUN curl --verbose --head --fail $URL 1>/dev/null
10+
11+
# Download into /perf_test & ensure that it works correctly
12+
RUN mkdir -p /perf_test && cd /perf_test && curl --location --silent --fail --output - $URL | tar x -z -v -f - --strip-components 1 && bin/runjava com.rabbitmq.perf.PerfTest --help
13+
WORKDIR /perf_test
14+
15+
ENTRYPOINT ["bin/runjava", "com.rabbitmq.perf.PerfTest"]

Makefile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ HARDWARE := $$(uname -m | tr '[:upper:]' '[:lower:]')
1111

1212
GPG_KEYNAME := $$(awk -F'[<>]' '/<gpg.keyname>/ { print $$3 }' pom.xml)
1313

14+
RELEASE_VERSION ?= 2.3.0
15+
1416
### TARGETS ###
1517
#
1618

@@ -23,12 +25,12 @@ native-image: clean ## Build the native image
2325
@mvnw -q package -DskipTests -P native-image -P '!java-packaging'
2426
native-image -jar target/perf-test.jar -H:Features="com.rabbitmq.perf.NativeImageFeature"
2527

26-
docker-image:
27-
rm -rf rabbitmq-perf-test-$(RELEASE_VERSION)*
28-
wget https://github.com/rabbitmq/rabbitmq-perf-test/releases/download/v$(RELEASE_VERSION)/rabbitmq-perf-test-$(RELEASE_VERSION)-bin.tar.gz
29-
tar -xf rabbitmq-perf-test-$(RELEASE_VERSION)-bin.tar.gz
30-
docker build --build-arg perf_test_distribution=rabbitmq-perf-test-$(RELEASE_VERSION) -t pivotalrabbitmq/perf-test:$(RELEASE_VERSION) -t pivotalrabbitmq/perf-test:latest .
31-
rm -rf rabbitmq-perf-test-$(RELEASE_VERSION)*
28+
.PHONY: docker-image
29+
docker-image: ## Build Docker image
30+
@docker build \
31+
--tag pivotalrabbitmq/perf-test:$(RELEASE_VERSION) \
32+
--tag pivotalrabbitmq/perf-test:latest \
33+
--build-arg perf_test_version=$(RELEASE_VERSION) .
3234

3335
.PHONY: package-native-image
3436
package-native-image: native-image ## Package the native image

0 commit comments

Comments
 (0)