From 65a39a92f6d321eab2864a89b25aafd7db8816da Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Thu, 23 May 2024 12:43:28 +0100 Subject: [PATCH 1/4] fix: drop PublishTrimmed from binary dist --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f8c015c..f20d7cb 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ RIDS = "linux-x64" "linux-arm64" "linux-musl-x64" "linux-musl-arm64" "osx-x64" " build: clean for rid in $(RIDS); do \ echo "Building for $$rid..."; \ - dotnet publish -c Release -p:PublishSingleFile=true -p:SelfContained=true -p:PublishReadyToRun=true -p:PublishTrimmed=true -p:StaticLink=true -r $$rid -o bin/$(APP_NAME)-$$rid; \ + dotnet publish -c Release -p:PublishSingleFile=true -p:SelfContained=true -p:PublishReadyToRun=true -p:StaticLink=true -r $$rid -o bin/$(APP_NAME)-$$rid; \ done || true # the above true condition is a yak shave, From 3ecd6623c04c71af36c79bb234aab035e321f5e4 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Thu, 23 May 2024 13:28:39 +0100 Subject: [PATCH 2/4] test: add Dockerfiles for debian/alpine --- Dockerfile.alpine | 17 +++++++++++++++++ Dockerfile.debian | 17 +++++++++++++++++ README.md | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.alpine create mode 100644 Dockerfile.debian diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 0000000..0263c3c --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,17 @@ +FROM alpine +RUN apk --no-cache add curl gcc icu + +RUN if [ "$(uname -m)" = "aarch64" ]; then \ + export BINARY_ARCH=arm64; \ + elif [ "$(uname -m)" = "x86_64" ]; then \ + export BINARY_ARCH=x64; \ + else \ + echo unsupported arch "$(uname -m)"; \ + exit 1; \ + fi && \ + curl -LO https://github.com/YOU54F/explore-cli/releases/download/0.6.0/explore-cli-linux-musl-$BINARY_ARCH.gz && \ + gunzip explore-cli-linux-musl-$BINARY_ARCH.gz && \ + chmod +x explore-cli-linux-musl-$BINARY_ARCH && \ + mv explore-cli-linux-musl-$BINARY_ARCH /usr/local/bin/explore-cli && \ + rm -rf explore-cli-linux-musl-$BINARY_ARCH.gz +ENTRYPOINT [ "explore-cli" ] \ No newline at end of file diff --git a/Dockerfile.debian b/Dockerfile.debian new file mode 100644 index 0000000..117a68f --- /dev/null +++ b/Dockerfile.debian @@ -0,0 +1,17 @@ +FROM debian:12-slim +RUN apt update && apt install -y libicu-dev + +RUN if [ "$(uname -m)" = "aarch64" ]; then \ + export BINARY_ARCH=arm64; \ + elif [ "$(uname -m)" = "x86_64" ]; then \ + export BINARY_ARCH=x64; \ + else \ + echo unsupported arch "$(uname -m)"; \ + exit 1; \ + fi && \ + curl -LO https://github.com/YOU54F/explore-cli/releases/download/0.6.0/explore-cli-linux-$BINARY_ARCH.gz && \ + gunzip explore-cli-linux-$BINARY_ARCH.gz && \ + chmod +x explore-cli-linux-$BINARY_ARCH && \ + mv explore-cli-linux-$BINARY_ARCH /usr/local/bin/explore-cli && \ + rm -rf explore-cli-linux-$BINARY_ARCH.gz +ENTRYPOINT [ "explore-cli" ] \ No newline at end of file diff --git a/README.md b/README.md index ea4bde9..708ded7 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Standalone releases of the Explore.CLI tool are published to GitHub Releases. ###### Debian -`apt update && apt install -y libicu` +`apt update && apt install -y libicu-dev` ### Session Cookies for CLI command From 69eaa162e0e24458b2f052b1906a2e0616468861 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Thu, 23 May 2024 14:40:27 +0100 Subject: [PATCH 3/4] docs: add docs for Dockerfile usage --- Dockerfile.debian | 2 +- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Dockerfile.debian b/Dockerfile.debian index 117a68f..f03c994 100644 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -1,5 +1,5 @@ FROM debian:12-slim -RUN apt update && apt install -y libicu-dev +RUN apt update && apt install -y curl libicu-dev RUN if [ "$(uname -m)" = "aarch64" ]; then \ export BINARY_ARCH=arm64; \ diff --git a/README.md b/README.md index 708ded7..281e619 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,53 @@ Standalone releases of the Explore.CLI tool are published to GitHub Releases. `apt update && apt install -y libicu-dev` +#### Docker + +Dockerfiles are provided for amd64 & arm64 flavours + +- Alpine + - `./Dockerfile.alpine` +- Debian + - `./Dockerfile.debian` + +##### Building images + +```sh +docker build . --platform=linux/arm64 -f Dockerfile.debian -t explore-cli:debian-arm64 +docker build . --platform=linux/arm64 -f Dockerfile.debian -t explore-cli:debian-amd64 +docker build . --platform=linux/arm64 -f Dockerfile.alpine -t explore-cli:alpine-arm64 +docker build . --platform=linux/arm64 -f Dockerfile.alpine -t explore-cli:alpine-amd64 +``` + +##### Using images + +The `entrypoint` is the `explore-cli` application. + +Set environment variables in your shell + +```sh +export EXPLORE_SESSION_TOKEN= +export EXPLORE_XSRF_TOKEN= +``` + +Run your created docker image, with your required explore-cli command. + +In our example we are using `import-spaces` which we have in our local directory under the `spaces` folder. + +The `spaces` folder is volume mounted into our container in `/spaces`, and commands to file paths should +reference this folder. + +```sh +docker run --platform=linux/amd64 \ + --rm \ + -it \ + -v $PWD/spaces:/spaces \ + explore-cli:debian \ + import-spaces \ + --explore-cookie "SESSION=${EXPLORE_SESSION_TOKEN}; XSRF-TOKEN=${EXPLORE_XSRF_TOKEN}" \ + -fp /spaces/explore_demo_spaces.json +``` + ### Session Cookies for CLI command You will need to obtain certain cookies from an active session in SwaggerHub Explore to invoke the `CLI` commands. From 4747efc28374b633b4549fb5652d2cd6d060aecd Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Thu, 23 May 2024 15:32:18 +0100 Subject: [PATCH 4/4] chore: update dl-link to smartbear-devrel --- Dockerfile.alpine | 2 +- Dockerfile.debian | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 0263c3c..0279358 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -9,7 +9,7 @@ RUN if [ "$(uname -m)" = "aarch64" ]; then \ echo unsupported arch "$(uname -m)"; \ exit 1; \ fi && \ - curl -LO https://github.com/YOU54F/explore-cli/releases/download/0.6.0/explore-cli-linux-musl-$BINARY_ARCH.gz && \ + curl -LO https://github.com/smartbear-devrel/explore-cli/releases/download/0.6.0/explore-cli-linux-musl-$BINARY_ARCH.gz && \ gunzip explore-cli-linux-musl-$BINARY_ARCH.gz && \ chmod +x explore-cli-linux-musl-$BINARY_ARCH && \ mv explore-cli-linux-musl-$BINARY_ARCH /usr/local/bin/explore-cli && \ diff --git a/Dockerfile.debian b/Dockerfile.debian index f03c994..2adde8c 100644 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -9,7 +9,7 @@ RUN if [ "$(uname -m)" = "aarch64" ]; then \ echo unsupported arch "$(uname -m)"; \ exit 1; \ fi && \ - curl -LO https://github.com/YOU54F/explore-cli/releases/download/0.6.0/explore-cli-linux-$BINARY_ARCH.gz && \ + curl -LO https://github.com/smartbear-devrel/explore-cli/releases/download/0.6.0/explore-cli-linux-$BINARY_ARCH.gz && \ gunzip explore-cli-linux-$BINARY_ARCH.gz && \ chmod +x explore-cli-linux-$BINARY_ARCH && \ mv explore-cli-linux-$BINARY_ARCH /usr/local/bin/explore-cli && \