From e45845f4b9665cc2aefb005e6fe8cd89b7453ffb Mon Sep 17 00:00:00 2001 From: Sebastian Mandrean Date: Thu, 12 Jan 2017 17:45:52 +0100 Subject: [PATCH 1/3] Make Docker shell script executable --- Tools/dockerfiles/Dockerfile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Tools/dockerfiles/Dockerfile b/Tools/dockerfiles/Dockerfile index a7b6782469..fc0b0cbf1a 100644 --- a/Tools/dockerfiles/Dockerfile +++ b/Tools/dockerfiles/Dockerfile @@ -6,15 +6,14 @@ RUN apt-get -qqy update && \ apt-get -qqy install wget unzip && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -RUN bash -c "\ - mkdir /opt/autorest && \ - cd /opt/autorest && \ - wget https://github.com/Azure/autorest/releases/download/AutoRest-0.16.0/autorest.0.16.0.zip && \ - unzip autorest.0.16.0.zip" ADD autorest /opt/autorest/autorest +RUN bash -c "cd /opt/autorest && \ + wget https://github.com/Azure/autorest/releases/download/AutoRest-0.16.0/autorest.0.16.0.zip && \ + unzip autorest.0.16.0.zip && \ + chmod +x /opt/autorest/autorest" + ENV PATH "$PATH:/opt/autorest/" -WORKDIR /opt/autorest/ \ No newline at end of file +WORKDIR /opt/autorest/ From 9ac73cbe38911e96ad47c274a1c843d5ca971b74 Mon Sep 17 00:00:00 2001 From: Sebastian Mandrean Date: Thu, 12 Jan 2017 18:19:47 +0100 Subject: [PATCH 2/3] Remove unnecessary dependencies --- Tools/dockerfiles/Dockerfile | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Tools/dockerfiles/Dockerfile b/Tools/dockerfiles/Dockerfile index fc0b0cbf1a..6bad5364f3 100644 --- a/Tools/dockerfiles/Dockerfile +++ b/Tools/dockerfiles/Dockerfile @@ -1,18 +1,19 @@ FROM mono:4.2 -# all in one RUN to produce less, smaller layers +ARG AUTOREST_VERSION=0.16.0 + +ADD autorest /opt/autorest/autorest + +# all-in-one RUN to produce smaller image with less layers RUN apt-get -qqy update && \ apt-get -qqy upgrade && \ - apt-get -qqy install wget unzip && \ + apt-get -qqy install bsdtar && \ apt-get clean && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -ADD autorest /opt/autorest/autorest + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ -RUN bash -c "cd /opt/autorest && \ - wget https://github.com/Azure/autorest/releases/download/AutoRest-0.16.0/autorest.0.16.0.zip && \ - unzip autorest.0.16.0.zip && \ - chmod +x /opt/autorest/autorest" + curl -#SL https://github.com/Azure/autorest/releases/download/AutoRest-$AUTOREST_VERSION/autorest.$AUTOREST_VERSION.zip | \ + bsdtar -xvf- -C /opt/autorest/ && \ + chmod +x /opt/autorest/autorest ENV PATH "$PATH:/opt/autorest/" From be3116728178e07d70ccea7a2fc5c675f5c798a1 Mon Sep 17 00:00:00 2001 From: Sebastian Mandrean Date: Thu, 12 Jan 2017 18:44:26 +0100 Subject: [PATCH 3/3] Update documentation for AutoRest Mono/Docker usage --- README.md | 32 +++++++++++++++++++++++++++++--- docs/index.html | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 35fcb6db28..6ddc263778 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,35 @@ Alternatively it can be installed from [Chocolatey](https://chocolatey.org/) by Nightlies are available via MyGet: [![AutoRest MyGet](https://img.shields.io/myget/autorest/vpre/autorest.svg?style=flat-square)](https://www.myget.org/gallery/autorest) -AutoRest can be run on OSX and Unix using Mono or by running Docker container: - - docker pull azuresdk/autorest:latest +AutoRest can be run on macOS and *nix using [Mono](http://www.mono-project.com/download): + + # Download & Unpack Autorest + curl -LO https://github.com/Azure/autorest/releases/download/AutoRest-0.16.0/autorest.0.16.0.zip && \ + unzip autorest.0.16.0.zip -d autorest/ && \ + cd autorest && \ + + # Download Swagger.json example + curl -O https://raw.githubusercontent.com/Azure/autorest/master/Samples/petstore/petstore.json && \ + + # Run AutoRest using mono + mono AutoRest.exe \ + -CodeGenerator CSharp \ + -Input petstore.json \ + -OutputDirectory CSharp_PetStore -Namespace PetStore + +Or [Docker](https://docs.docker.com/engine/installation): + + # Download Swagger.json example + curl -O https://raw.githubusercontent.com/Azure/autorest/master/Samples/petstore/petstore.json + + # Download latest AutoRest Docker image + docker pull azuresdk/autorest:latest + + # Run AutoRest using Docker, mounting the current folder (pwd) into /home inside the container + docker run -it --rm -v $(pwd):/home azuresdk/autorest:latest autorest \ + -CodeGenerator CSharp \ + -Input /home/petstore.json \ + -OutputDirectory /home/CSharp_PetStore -Namespace PetStore ## Building AutoRest AutoRest is developed primarily in C# but generates code for multiple languages. See [this link](docs/developer/guide/building-code.md) to build and test AutoRest. diff --git a/docs/index.html b/docs/index.html index 4195a29887..2621c9b953 100644 --- a/docs/index.html +++ b/docs/index.html @@ -41,9 +41,38 @@

Nightlies are available via MyGet: AutoRest MyGet

-

AutoRest can be run on OSX and Unix using Mono or by running Docker container:

+

AutoRest can be run on macOS and *nix using Mono:

+ +
+# Download & Unpack Autorest
+curl -LO https://github.com/Azure/autorest/releases/download/AutoRest-0.16.0/autorest.0.16.0.zip && \
+unzip autorest.0.16.0.zip -d autorest/ && \
+cd autorest && \
+
+# Download Swagger.json example
+curl -O https://raw.githubusercontent.com/Azure/autorest/master/Samples/petstore/petstore.json && \
+
+# Run AutoRest using mono
+mono AutoRest.exe \
+  -CodeGenerator CSharp \
+  -Input petstore.json \
+  -OutputDirectory CSharp_PetStore -Namespace PetStore
+
+ +

Or using Docker:

+ +
+# Download Swagger.json example
+curl -O https://raw.githubusercontent.com/Azure/autorest/master/Samples/petstore/petstore.json
+
+# Download latest AutoRest Docker image
+docker pull azuresdk/autorest:latest
 
-
docker pull azuresdk/autorest:latest
+# Run AutoRest using Docker, mounting the current folder (pwd) into /home inside the container
+docker run -it --rm -v $(pwd):/home azuresdk/autorest:latest autorest \
+  -CodeGenerator CSharp \
+  -Input /home/petstore.json \
+  -OutputDirectory /home/CSharp_PetStore -Namespace PetStore