Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
Adds Dockerfile for CLI.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcornish committed Mar 8, 2018
1 parent d6f6bfd commit 7676cdd
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 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" ]
26 changes: 26 additions & 0 deletions 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/).
30 changes: 30 additions & 0 deletions cli/files/fetch-source.sh
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

set -e

if [[ $# -lt 2 ]]; then
echo "Usage: $( basename $0 ) <CLI_VERSION> <RELEASE_TYPE>"
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

0 comments on commit 7676cdd

Please sign in to comment.