From 7a0b4ac76d4de79d54e1a108abbaa6eded88e671 Mon Sep 17 00:00:00 2001 From: lepapareil Date: Sat, 11 Dec 2021 19:23:30 +0100 Subject: [PATCH] Update docker contrib with lightweight alpine based image --- contrib/docker/Dockerfile | 18 ++++++++++++------ contrib/docker/README | 10 ---------- contrib/docker/README.md | 25 +++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 16 deletions(-) delete mode 100644 contrib/docker/README create mode 100644 contrib/docker/README.md diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile index f9277b1ef..79da1d44b 100644 --- a/contrib/docker/Dockerfile +++ b/contrib/docker/Dockerfile @@ -1,7 +1,13 @@ -FROM debian:10.10 -RUN apt update && apt install -y wget curl libxml2 - -ARG VERSION -RUN wget https://github.com/Orange-OpenSource/hurl/releases/download/${VERSION}/hurl_${VERSION}_amd64.deb -RUN apt install ./hurl_${VERSION}_amd64.deb +FROM alpine:3.15 AS builder +WORKDIR /tmp +RUN apk add git jq curl cargo gcc libffi-dev libxml2-dev libxml2-utils openssl-dev +RUN git clone --quiet --depth 1 --branch $(curl --silent "https://api.github.com/repos/Orange-OpenSource/hurl/releases/latest" | jq -r .tag_name) https://github.com/Orange-OpenSource/hurl.git +WORKDIR /tmp/hurl +RUN cargo build --release --verbose --bin hurl +FROM alpine:3.15 AS runner +COPY --from=builder /tmp/hurl/target/release/hurl /usr/sbin/ +COPY --from=builder /usr/lib/libxml2.so.2 /usr/lib/ +COPY --from=builder /usr/lib/libgcc_s.so.1 /usr/lib/ +COPY --from=builder /usr/lib/liblzma.so.5 /usr/lib/ +ENTRYPOINT ["/usr/sbin/hurl"] diff --git a/contrib/docker/README b/contrib/docker/README deleted file mode 100644 index bdbd2af20..000000000 --- a/contrib/docker/README +++ /dev/null @@ -1,10 +0,0 @@ -#export VERSION=$(grep '^version' ../../packages/hurl/Cargo.toml | cut -f2 -d'"') -export VERSION=1.4.0 - -# Build image -docker build . -t hurl:$VERSION --build-arg VERSION=$VERSION - -# Run -docker run hurl:$VERSION hurl --version - - diff --git a/contrib/docker/README.md b/contrib/docker/README.md new file mode 100644 index 000000000..6f2ad8ba5 --- /dev/null +++ b/contrib/docker/README.md @@ -0,0 +1,25 @@ +# Build image + +``` +docker build --tag hurl:latest . +``` + +# Get docker hurl version + +``` +docker run --rm hurl:latest --version +``` + +# Run docker hurl from STDIN + +``` +echo -e "GET https://hurl.dev\n\nHTTP/1.1 200" | docker run --rm -i hurl:latest --test --color +``` + +# Run docker hurl from FILE + +``` +echo -e "GET https://hurl.dev\n\nHTTP/1.1 200" > /tmp/test.hurl +ocker run --rm -v /tmp/test.hurl:/tmp/test.hurl -w /tmp hurl:latest --test --color /tmp/test.hurl +``` +