Skip to content

Instantly share code, notes, and snippets.

@mscottford

mscottford/Dockerfile

Last active Jan 31, 2018
Embed
What would you like to do?
Docker and docker-compose setup for a simple node environment which is setup to support using `yarn` and `yo`

Run Yarn and Yeoman in a Docker container

Part of my mission to not install any dev tools or dev environments outside of Docker.

Build container

Run docker-compose build.

Get a bash prompt in the container

Run docker-compose run app bash.

Start a new project with yarn

Either:

docker-compose run app bash
yarn init

or:

docker-compose run app yarn init

Adding additonal yeoman generators:

  1. Modify Dockerfile to globally include additional generators

    • example: Add RUN yarn globa add generator-exrpess to the end of the Dockerfile
  2. Run docker-compose build to rebuild the container

  3. Either:

    docker-compose run app bash
    yo express
    

    or:

    docker-compose run app yo express
    
version: "2"
services:
app:
build: .
working_dir: /home/docker/app
environment:
- NODE_ENV=production
volumes:
- ./:/home/docker/app
FROM node:9.3
RUN apt-get update
RUN apt-get install sudo
RUN adduser --disabled-password --gecos '' docker
RUN adduser docker sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER docker
RUN sudo apt-get update
RUN sudo apt-get install apt-transport-https
RUN sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
RUN sudo echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
RUN sudo apt-get update
RUN sudo apt-get install yarn
ENV PATH=/home/docker/.yarn/bin:$PATH
RUN yarn global add yo
@joshkel

This comment has been minimized.

Copy link

@joshkel joshkel commented Jan 19, 2018

Nitpick: "Yeoman," not "Yoeman."

(I need to learn Docker. Thanks for the reminder.)

@mscottford

This comment has been minimized.

Copy link
Owner Author

@mscottford mscottford commented Jan 31, 2018

Thanks for pointing that out! I've updated it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.