Run your Grommet app inside a Docker container
JavaScript HTML CSS
Latest commit 40adb7c Jan 11, 2017 @sgelliott sgelliott Package repository update
Permalink
Failed to load latest commit information.
dist first commit Jan 11, 2017
server first commit Jan 11, 2017
src first commit Jan 11, 2017
.babelrc first commit Jan 11, 2017
.dockerignore first commit Jan 11, 2017
.gitignore first commit Jan 11, 2017
Dockerfile first commit Jan 11, 2017
README.md first commit Jan 11, 2017
customEslintrc.json first commit Jan 11, 2017
docker-compose.yml first commit Jan 11, 2017
grommet-toolbox.config.js first commit Jan 11, 2017
gulpfile.babel.js first commit Jan 11, 2017
package.json Package repository update Jan 11, 2017

README.md

Grommet Docker Basic

This is a basic Grommet project (using the sample-app generated by Grommet) running in a Docker container configuration.

Setup

Using Dockerfile

First, build your custom Docker image from the Dockerfile. In this case I'm tagging it with lodgik/grommet but you can use any name you like for your new image.

docker build -t lodgik/grommet .

Once the image is built, run a Docker container from that image. Be sure to update the command below with whatever name you chose for your custom image in the above command.

docker run --name grommet -d -p 9000:9000 lodgik/grommet

Using Docker Compose

Docker Compose lets us script and automate the Docker image build and container spin up. It's very convenient if you want to avoid using the command line constantly.

To use compose, simply execute this command: docker-compose up -d. The -d option allows the new container to run in the background.

It pulls configuration from the docker-compose.yml file and generally does the same thing as the two Docker commands in the Dockerfile section above.

NOTES

  • This configuration uses the official Node Docker image 6.9.4 (you can update the version in the Dockerfile)
  • Do not try to use the Docker node-alpine images. Because Grommet uses node-sass the way it does, you'll get compilation errors when building the Grommet Docker image
  • In this example, I used the Grommet sample-app which is generated as described in the Grommet Getting Started documentation
  • I use Node Express to serve the static index.html file generated from Grommet's distribution files. I did this for simplicity. Not necessarily a good option for your production needs.
  • You'll see a ton of command line output during build. This is coming frrom a setting in the base Node Docker image. You can ignore it.

Dockefile Customizations

If you're not using Grommet's gulp dist option, you can remove those related RUN commands from the Dockerfile. They are specific to this configuration.

Also you'll notice a RUN command in the Dockefile - RUN npm rebuild node-sass@3.13.1. This forces node-sass to be built for the container's platform. Since it's a binary, I do this to ensure that node-sass is properly built before running npm install. I will be testing to see if this can be removed, but haven't had the time yet.

Special Thanks

Thank you to Ejaz for asking me about an issue he was having with Node on Alpine which inspired me to create this solution.