Last active
February 13, 2017 07:32
-
-
Save grayside/cec46c14ed2b408377ea83610cf6d35c to your computer and use it in GitHub Desktop.
Dockerfile for running Phase2 Yeoman generators and capturing the output via a volume mount.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "2.1" | |
services: | |
# Run the gadget generator. | |
gadget: | |
extends: base | |
entrypoint: [ "yo", "gadget", "--no-insight", "--skip-install" ] | |
# Run the pattern-label-starter generator. | |
pls: | |
extends: base | |
entrypoint: [ "yo", "pattern-lab-starter", "--no-insight", "--skip-install" ] | |
# Run the generator-p2 generator. Extends from 'cli' service because we | |
# cannot install private libraries in the Dockerfile. | |
p2: | |
extends: cli | |
entrypoint: [ "yo", "p2", "--no-insight", "--skip-install" ] | |
# Run the generator-p2-env generator. Extends from 'cli' service because we | |
# cannot install private libraries in the Dockerfile. | |
p2-env: | |
extends: cli | |
entrypoint: [ "yo", "p2-env", "--no-insight", "--skip-install" ] | |
# Run the generator-p2-env generator. Extends from 'cli' service because we | |
# cannot install private libraries in the Dockerfile. | |
p2-jenkins: | |
extends: cli | |
entrypoint: [ "yo", "p2-env:jenkins", "--no-insight", "--skip-install" ] | |
# Run the generator-p2-env generator. Extends from 'cli' service because we | |
# cannot install private libraries in the Dockerfile. | |
p2-env-test: | |
extends: cli | |
entrypoint: "npm test" | |
working_dir: /usr/local/lib/node_modules/generator-p2-env | |
# Facilitates development against local clones of the "private" generators. | |
# The source location of the volume mounts is arbitrary. The destination is | |
# the global install path for npm inside the container and simulates the | |
# result of installing properly. | |
# | |
# From inside the container you can navigate to the projects in this location | |
# and run npm install or (from generator-p2) npm link generator-p2-env. | |
cli: | |
extends: base | |
entrypoint: /bin/sh | |
volumes: | |
- ./generator-p2:/usr/local/lib/node_modules/generator-p2 | |
- ./generator-p2-env:/usr/local/lib/node_modules/generator-p2-env | |
# Provides a common baseline of assembling the Docker image and output | |
# location of the generated code. | |
# | |
# All generated output via normal use of this Dockerfile outputs code in | |
# '~/Projects/newproject', however you can run with YO_PROJECT_DIRECTORY | |
# environment variable to choose a different location. | |
base: | |
build: . | |
network_mode: "bridge" | |
volumes: | |
- ${YO_PROJECT_DIRECTORY:-~/Projects/newproject}:/generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:4-alpine | |
ENV YO_P2_VERSION 2.2.0 | |
ENV PATTERN_LAB_STARTER_VERSION 2.0.0 | |
ENV GADGET_VERSION 1.0.0-rc1 | |
ENV P2_ENV_VERSION 1.2.0 | |
RUN node -v | |
RUN npm -v | |
RUN echo "Yeoman Doctor will warn about our npm version being outdated. It is expected and OK." | |
RUN npm install --global --silent yo | |
RUN npm install --global --silent generator-gadget@v$GADGET_VERSION | |
RUN npm install --global --silent generator-pattern-lab-starter@v$PATTERN_LAB_STARTER_VERSION | |
# These generators remain private and so cannot be installed yet. | |
# RUN npm install --global --silent git+ssh://bitbucket.org/phase2tech/generator-p2.git#v$YO_P2_VERSION | |
# RUN npm install --global --silent git+ssh://bitbucket.org/phase2tech/generator-p2-env.git#v$P2_ENV_VERSION | |
# Add a yeoman user because Yeoman freaks out and runs setuid(501). | |
# This was because less technical people would run Yeoman as root and cause problems. | |
# Setting uid to 501 here since it's already a random number being thrown around. | |
# @see https://github.com/yeoman/yeoman.github.io/issues/282 | |
# @see https://github.com/cthulhu666/docker-yeoman/blob/master/Dockerfile | |
RUN adduser -D -u 501 yeoman && \ | |
echo "yeoman ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | |
# Yeoman needs the use of a home directory for caching and certain config storage. | |
ENV HOME /home/yeoman | |
RUN mkdir /generated && chown yeoman:yeoman /generated | |
WORKDIR /generated | |
# Always run as the yeoman user | |
USER yeoman | |
CMD /bin/sh | |
# Run a Yeoman generator with a command such as: | |
# docker build -t yeoman . | |
# docker run -it -v "/Users/username/Projects/newproject:/generated" --rm yeoman yo gadget --no-insight --skip-install | |
# The --no-insight flag is recommended to avoid prompts for usage collection. | |
# @see https://github.com/yeoman/yo/issues/20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment