From 7676cdd25a6a79a38428e1a48909a4a05c5c3771 Mon Sep 17 00:00:00 2001 From: Pete Cornish Date: Wed, 28 Feb 2018 11:53:15 +0000 Subject: [PATCH] Adds Dockerfile for CLI. --- cli/Dockerfile | 19 +++++++++++++++++++ cli/README.md | 26 ++++++++++++++++++++++++++ cli/files/fetch-source.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 cli/Dockerfile create mode 100644 cli/README.md create mode 100644 cli/files/fetch-source.sh diff --git a/cli/Dockerfile b/cli/Dockerfile new file mode 100644 index 0000000..3e3d363 --- /dev/null +++ b/cli/Dockerfile @@ -0,0 +1,19 @@ +FROM openjdk:8 AS build + +ARG CLI_VERSION="0.3.0" +ARG RELEASE_TYPE="tag" + +COPY files /tmp +RUN chmod +x /tmp/fetch-source.sh && \ + /tmp/fetch-source.sh ${CLI_VERSION} ${RELEASE_TYPE} + +WORKDIR /tmp/apiman-cli +RUN chmod +x /tmp/apiman-cli/gradlew && \ + ./gradlew shadowJar + +FROM openjdk:8-jre-alpine + +RUN mkdir -p /opt/apiman-cli/lib +COPY --from=build /tmp/apiman-cli/build/libs/* /opt/apiman-cli/lib/ + +ENTRYPOINT [ "java", "-jar", "/opt/apiman-cli/lib/apiman-cli.jar" ] diff --git a/cli/README.md b/cli/README.md new file mode 100644 index 0000000..ccd5cb3 --- /dev/null +++ b/cli/README.md @@ -0,0 +1,26 @@ +apiman cli +========== + +## Usage + +To use apiman CLI + + docker run -it apiman/cli [args] + +For valid arguments, please see the documentation for [apiman CLI](https://github.com/apiman/apiman-cli) + +## Building the image + + docker build -t="apiman/cli" --rm . + +### Building from a branch + +If you're a developer working on this project, or you want the latest edge version, you can build from a branch of the apiman-cli repository. + +To do this, specify the RELEASE_TYPE as 'branch' and the CLI_VERSION as the branch name: + + docker build -t="apiman/cli:beta" --build-arg RELEASE_TYPE=branch --build-arg CLI_VERSION="develop" --rm . + +## Image accessible on Docker hub + +This image is automatically built and published into [Docker Hub](https://registry.hub.docker.com/u/apiman/cli/). diff --git a/cli/files/fetch-source.sh b/cli/files/fetch-source.sh new file mode 100644 index 0000000..7b3a6e3 --- /dev/null +++ b/cli/files/fetch-source.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -e + +if [[ $# -lt 2 ]]; then + echo "Usage: $( basename $0 ) " + exit 1 +fi + +CLI_VERSION="$1" +RELEASE_TYPE="$2" + +case "${RELEASE_TYPE}" in + tag) + SOURCE_URL="https://codeload.github.com/apiman/apiman-cli/zip/v${CLI_VERSION}" + ;; + branch) + SOURCE_URL="https://codeload.github.com/apiman/apiman-cli/zip/${CLI_VERSION}" + ;; + *) + echo "Release type must be branch or tag" + exit 1 + ;; +esac + +echo -e "Downloading source from: ${SOURCE_URL}" +curl -s ${SOURCE_URL} -o /tmp/apiman-cli.zip + +unzip /tmp/apiman-cli.zip -d /tmp +mv /tmp/apiman-cli-* /tmp/apiman-cli