Skip to content

Instantly share code, notes, and snippets.

@fjenett
Last active June 13, 2018 18:54
Show Gist options
  • Save fjenett/1d2789ca351305c52432 to your computer and use it in GitHub Desktop.
Save fjenett/1d2789ca351305c52432 to your computer and use it in GitHub Desktop.
Dockerfile for react.js / Sass app based on brunch.io

React.js & Sass on brunch.io

Dockerfile for image using Node.js 0.11 with React.js and Sass running on brunch.io

Build doing something like

cd /Users/fjenett/Desktop/docker-brunch-sass-react
docker build -t fjenett/brunch-react-sass /Users/fjenett/ .

See here for more details: https://github.com/fjenett/brunch-react-sass

FROM node:0.11
MAINTAINER Florian Jenett
# add brunch.io
RUN npm install -g brunch
RUN brunch --version
# add bower.io
RUN npm install -g bower
RUN brunch --version
# add user for brunch
RUN useradd bruncher && echo "bruncher:bruncher" | chpasswd
RUN mkdir -p /home/bruncher && chown -R bruncher:bruncher /home/bruncher
RUN mkdir /app && chown -R bruncher:bruncher /app
RUN echo "2015-01-01 10:59:19 - fjenett"
# fetch base app skeleton, could use `brunch new` but that fails ...
RUN git clone https://github.com/fjenett/brunch-react-sass.git /app
WORKDIR /app
USER bruncher
RUN bower install
USER root
# add plugins and libraries
RUN npm install
RUN echo "2015-01-01 13:52:57 - fjenett"
# add watch helper
COPY ./watch-helper.sh /usr/local/bin/watch-helper.sh
RUN chmod +x /usr/local/bin/watch-helper.sh
EXPOSE 80
#ENV DEBUG brunch:*
# kicks on the server
CMD ["brunch", "watch"]
#! /bin/bash
# currently having trouble with a linked-in volume (folder) and
# `brunch watch` not receiving change events ... forcing this for now
# with a deamon
# http://stackoverflow.com/questions/6475252/bash-script-watch-folder-execute-command#9461685
brunch_watch_helper() {
dir="$1"
chsum1=""
echo "watch helper is watching $dir"
while [[ true ]]
do
# calc new checksum every second
touch --date=@"$( date -d '3 seconds ago' +%s )" /tmp/newerthan
chsum2=$( find "$dir" -type f -newer /tmp/newerthan -exec md5sum {} \; )
if [[ $chsum1 != $chsum2 ]] ; then
# touch if changed
for f in $( find "$dir" -type f -newer /tmp/newerthan ); do
echo $f;
ts=$( stat -c %Y "$f" )
touch --date=@"$ts" "$f"
done
chsum1=$chsum2
fi
sleep 2
done
}
brunch_watch_helper "$1"
@philss
Copy link

philss commented Apr 10, 2016

@fjenett you can try to set the option usePooling to true in your brunch config file, and avoid the brunch_watch_helper that you wrote.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment