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

Add docker to yeoman generator #200

Merged
merged 5 commits into from
May 25, 2016
Merged

Add docker to yeoman generator #200

merged 5 commits into from
May 25, 2016

Conversation

withinboredom
Copy link
Contributor

@withinboredom withinboredom commented May 21, 2016

This PR adds a simple docker-compose.yml file and a simple Dockerfile to the yeoman generator to allow people to quickly get up and running with Docker. This will be helpful for developers using Windows.

@CLAassistant
Copy link

CLAassistant commented May 21, 2016

CLA assistant check
All committers have signed the CLA.

@gigabo
Copy link
Contributor

gigabo commented May 21, 2016

Yeah! 🤘

This is awesome! I need to get set up with a modern docker to try it out.

@doug-wade - You're most familiar with this yeoman generator. Take a look at this!

npm start
```

Then go to [localhost:3000](http://localhost:3000/). You will see a simple page that pre-renders and that is interactive on load. It also will include hot reloading of React components in their own file.

If you want to optimize the client code at the expense of startup time, type `NODE_ENV=production npm start`. You can also use any of [the other arguments for react-server-cli](../../react-server-cli#setting-options-manually) after `--`. For example:

```
```shell
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. Nice to have syntax coloring on these.

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 Thanks for adding this!

@gigabo gigabo added the enhancement New functionality. label May 21, 2016
"env": {
"docker": {
"host": "Your ip from `docker-machine ip` here"
},
Copy link
Contributor

@gigabo gigabo May 22, 2016

Choose a reason for hiding this comment

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

This is cool. Nice use of environment configuration.

Thanks for the added documentation. Clears it right up for me.

@gigabo
Copy link
Contributor

gigabo commented May 22, 2016

This looks great to me. 👍

I'd like to wait until @doug-wade has had a chance to look over it, too, since he knows this generator well.

@doug-wade - Is this something that would be easy for us to prompt the user for down the road? Like want to run in a docker container? Yes/no and conditionally include this stuff?

"port": "80"
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just occurred to me that we should probably generate this config. #203

@gigabo
Copy link
Contributor

gigabo commented May 23, 2016

Hey, I just tried this locally. The README changes showed up, but the dockerfile and the docker-compose.yml didn't... @doug-wade is there something else that needs to happen for new files to get picked up?

@doug-wade
Copy link
Collaborator

@withinboredom This is pretty awesome! As @gigabo notes, there are still some things we'll want you to do before you merge

  1. I don't match files with globs currently, even though I should. For now, you'll need to enumerate the new files in one of the two lists of files that are operated on by the generator (one is for dotfiles that are used by git and babel for configuration, which I preface with _ rather than . to prevent them interacting with the monorepo; you may want to add your docker config there to make it easier to develop on Docker, though I'm not sure; if there isn't a risk of interaction, there is also one for files that are not renamed.
  2. Not all clients will want to include a Docker container with their new react-server project, so we should prompt them (Yeoman uses Inquirer for prompting ), and only generate the Docker config if the user asks for it (my first intuition is to default to no Docker config, personally, since we push the Yeoman generator as an easy way to get started, and the Docker config makes react-server look bigger and scarier to a new developer; honestly I should put the linter behind an Inquirer prompt for the same reason)

@withinboredom
Copy link
Contributor Author

@doug-wade,

I added the docker files as a prompt, and included changes to the unit tests. I can't get the new test (where dockerCfg is true) to pass, although I tested locally and it seems to function as expected. Maybe you can take a gander and give me a hint as to what I did wrong?

@withinboredom
Copy link
Contributor Author

withinboredom commented May 24, 2016

Also, it seems like a good idea to wait for #203 before generating the config for a dockerish runtime and I think its a good idea to leave that in the README for now. What do you think?

@gigabo
Copy link
Contributor

gigabo commented May 24, 2016

wait for #203 before generating the config

Makes sense.

@gigabo
Copy link
Contributor

gigabo commented May 24, 2016

Alright! It's loading for me!

But... static assets aren't, yet.

image

Still trying to fetch through localhost. Did I mess up my config, or is there a bug somewhere?

$ cat .reactserverrc
{
  "port": "3000",
  "env": {
    "docker": {
      "host": "192.168.99.100"
    }
  }
}

@withinboredom
Copy link
Contributor Author

I had issues with the config as well, I figured it was environmental ... guess I should open an issue. You can modify the script in package.json, here's mine for example:

{
  "name": "reactFrontend",
  "version": "0.0.1",
  "description": "A react-server instance",
  "main": "HelloWorld.js",
  "scripts": {
    "start": "react-server-cli --host 192.168.99.100", 
    "test": "xo && nsp check"
  },
  "license": "Apache-2.0",
  "dependencies": {
    "babel-plugin-transform-runtime": "^6.8.0",
    "babel-preset-es2015": "^6.6.0",
    "babel-preset-react": "^6.5.0",
    "babel-runtime": "^6.6.1",
    "react": "~0.14.2",
    "react-dom": "~0.14.2",
    "react-server": "^0.2.10",
    "react-server-cli": "^0.2.10",
    "superagent": "1.2.0"
  },
  "devDependencies": {
    "eslint-config-xo-react": "^0.7.0",
    "eslint-plugin-react": "^5.1.1",
    "nsp": "^2.3.3",
    "xo": "^0.15.1"
  },
  "xo": {
    "esnext": true,
    "extends": "xo-react",
    "ignores": ["__clientTemp/**/*"]
  }
}

@withinboredom
Copy link
Contributor Author

You can verify that the environment is set right by changing the hello world:

Hello, World: {process.env.NODE_ENV}

@withinboredom
Copy link
Contributor Author

I think I found the bug ... trying a fix and PR if that was it. Not really setup to debug CLI scripts, so console.logging all over ;)

@withinboredom
Copy link
Contributor Author

Yep, fixed in #206 ... that was a fun one.

@gigabo
Copy link
Contributor

gigabo commented May 24, 2016

modify the script in package.json

Sweet, that worked. Thanks.

Mind rebasing this branch to pick up your fix from #206 now that it's merged?

I'll see if I can track down what's going wrong with the tests.

@gigabo
Copy link
Contributor

gigabo commented May 24, 2016

@doug-wade - Uhh.... why aren't the tests passing here? Seems right.

@doug-wade doug-wade mentioned this pull request May 24, 2016
@doug-wade
Copy link
Collaborator

@withinboredom The bug was in the tests, not in your changes 🐑 . #207 should unblock you

@doug-wade
Copy link
Collaborator

@withinboredom I think its failing with a (well-obscured) linter failure; I've added a line comment

@@ -14,6 +14,11 @@ module.exports = yeoman.Base.extend({
name: 'name',
message: 'What would you like to call your app?',
default: this.appname
},{
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is causing the linter failure that's failing your build; it should be }, {

Copy link
Contributor

Choose a reason for hiding this comment

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

@doug-wade - How did you track that down? I don't see anything about it in travis...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I ran the branch locally to find #207 and when I verified that it made the existing tests pass, I noticed there was still a linter failure.

@doug-wade
Copy link
Collaborator

doug-wade commented May 25, 2016

lgtm 👍
@gigabo anything else before we merge this?

@gigabo
Copy link
Contributor

gigabo commented May 25, 2016

This is awesome! Thanks @withinboredom!

I hope we'll see more cool stuff from you soon. 👹

@gigabo gigabo merged commit e5f96fb into redfin:master May 25, 2016
@gigabo
Copy link
Contributor

gigabo commented May 25, 2016

BTW - I'm testing out a changelog generator.

The next version's shaping up to be the @withinboredom show:


Unreleased (2016-05-25)

Bug fix

  • react-server-cli

Enhancement

Commiters: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants