From 238c6b7d390b6acef38612eb6afe040ff2210d04 Mon Sep 17 00:00:00 2001 From: Pratik raj Date: Mon, 28 Dec 2020 16:38:37 +0530 Subject: [PATCH 1/2] feat: build and run from Docker Support Build and run the generator from docker image support added. The main aim and motivation behind doing this is, because of a no. of different generator are there, which are compatible and works with the different version of generator and also might be incompatible with other generator or versions of generator Signed-off-by: Pratik Raj --- README.md | 34 ++++++++++++++++++++++++++++++++++ docker/Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 docker/Dockerfile diff --git a/README.md b/README.md index bef46c82..43ebe858 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,40 @@ * `yo generator` shows a wizard for generating a new generator * `yo generator:subgenerator ` generates a subgenerator with the name `` +## Using Docker + +Download the Dockerfile: + +```bash +mkdir docker +cd docker +wget https://github.com/yeoman/generator-generator/raw/master/docker/Dockerfile +``` + +Build the Docker images: + +```bash +docker build -t yeoman-generator:latest . +``` + +Make a folder where you want to generate the generator: + +```bash +mkdir generator +cd generator +``` + +Run the generator from image to generate generator: + +```bash +docker run -it --rm -v $PWD:/home/yeoman/generator yeoman-generator +``` + +Run and attach interactive shell to the generator docker container to work from inside the running container: + +```bash +docker run -it --rm -v $PWD:/home/yeoman/generator yeoman-generator /bin/bash +``` ## What do you get? diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..532ceb78 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,37 @@ +FROM ubuntu:20.04 +RUN \ + # configure the "yeoman" user + groupadd yeoman && \ + useradd yeoman -s /bin/bash -m -g yeoman -G sudo && \ + echo 'yeoman:yeoman' |chpasswd && \ + mkdir /home/yeoman/generator && \ + export DEBIAN_FRONTEND=noninteractive && \ + export TZ=Europe\Paris && \ + ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \ + apt-get update && \ + # install utilities + apt-get install -y \ + wget \ + sudo && \ + # install node.js + wget https://nodejs.org/dist/v12.18.3/node-v12.18.3-linux-x64.tar.gz -O /tmp/node.tar.gz && \ + tar -C /usr/local --strip-components 1 -xzf /tmp/node.tar.gz && \ + # install yeoman + npm install -g yo && \ + # cleanup + apt-get clean && \ + rm -rf \ + /home/yeoman/.cache/ \ + /var/lib/apt/lists/* \ + /tmp/* \ + /var/tmp/* + +# install generator +RUN npm install -g generator-generator + +# expose the working directory +USER yeoman +ENV PATH $PATH:/usr/bin +WORKDIR "/home/yeoman/generator" +VOLUME ["/home/yeoman/generator"] +CMD ["yo", "generator"] \ No newline at end of file From 939440e234b4966666fb027283a8e0a2913db8c7 Mon Sep 17 00:00:00 2001 From: Pratik Raj Date: Thu, 23 Mar 2023 19:17:20 +0530 Subject: [PATCH 2/2] feat: use latest LTS version of Node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ulises Gascón --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 532ceb78..ded684b6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,7 +14,7 @@ RUN \ wget \ sudo && \ # install node.js - wget https://nodejs.org/dist/v12.18.3/node-v12.18.3-linux-x64.tar.gz -O /tmp/node.tar.gz && \ + wget https://nodejs.org/dist/v18.15.0/node-v18.15.0-linux-x64.tar.gz -O /tmp/node.tar.gz && \ tar -C /usr/local --strip-components 1 -xzf /tmp/node.tar.gz && \ # install yeoman npm install -g yo && \