generator-static-dockerfile
v0.3.0
Published
Easily add a Dockerfile to serve your static site with standard Nginx. Choose your base directory to be served (e.g. dist / build).
Downloads
7
Maintainers
Readme
generator-static-dockerfile
Easily add a Dockerfile to serve your static site with standard Nginx. Choose your base directory to be served (e.g. dist or build).
What's generated?
A Dockerfile and an .nginx.conf are generated at the root of the current directory. They're basic configurations and focused on serving static files, and only expose port 80 (HTTP) for now.
Installation
First, install Yeoman and generator-static-dockerfile using npm (we assume you have pre-installed node.js).
npm install -g yo
npm install -g generator-static-dockerfile
Then generate the Dockerfile in an existing project:
yo static-dockerfile [folder]
If you don't pass [folder] when calling yo, you will be prompted to give it. You can leave it blank, if you want to serve files from your current root folder.
Make sure that your build / dist folder is NOT .gitignore'd!
If you've used a generator to bootstrap your site, there's 90% chance the static output folder is listed in .gitignore
(e.g. Yeoman with the dist
folder).
So remove that folder from your .gitignore
and make sure it is commited.
If you don't consider this a best-practice (and you'd be right), then you'll have to find a way to get the content of that static output folder pushed into your Docker container.
Getting To Know Yeoman
Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced. Feel free to learn more about him.
License
MIT © Julien M.