Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: build and run from Docker Support #241

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,40 @@
* `yo generator` shows a wizard for generating a new generator
* `yo generator:subgenerator <name>` generates a subgenerator with the name `<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?

Expand Down
37 changes: 37 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the TZ should be Paris? Do we require to have TZ specifically defined ?

I believe that the user can always provide that as a env argument:

docker run -rm -e TZ=Europe/Madrid -it myimage

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/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 && \
# 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"]