Skip to content

Instantly share code, notes, and snippets.

@Lewiscowles1986
Last active May 7, 2022 12:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lewiscowles1986/d4ef75a2d9c3e7d6e1794c3e90246c9a to your computer and use it in GitHub Desktop.
Save Lewiscowles1986/d4ef75a2d9c3e7d6e1794c3e90246c9a to your computer and use it in GitHub Desktop.
Bigcommerce Stencil Dockerfile

Easiest way to work with this

  1. Setup Docker
wget https://gist.github.com/Lewiscowles1986/d4ef75a2d9c3e7d6e1794c3e90246c9a/raw/{Dockerfile,docker-entrypoint.sh}
chmod +x docker-entrypoint.sh
docker build --force-rm -t stencil-xenial .
docker run --rm -v ~/clients/{whoever}/.stencil:/etc/stencil/.stencil -v `pwd`/theme:/opt/stencil -it stencil-xenial

You don't have to mount .stencil

You don't have to mount a theme folder if you don't plan on editing files

The container destroys itself after every exit (it's designed to be ephemeral with you maintaining your own stencil theme files)

#!/bin/bash
set -e
source $NVM_DIR/nvm.sh
if [ "$1" == "bash" ]; then
bash
elif [ "$1" == "start" ]; then
if [ ! -e "/opt/stencil/package.json" ]; then
if [ ! "$(ls -A /opt/stencil)" ]; then
git clone git://github.com/bigcommerce/stencil.git /opt/stencil
else
echo "/opt/stencil must either be empty, or hold a valid stencil theme"
fi
fi
if [ ! -e "/opt/stencil/node_modules" ]; then
npm install --loglevel=error
fi
if [ ! -e "/opt/stencil/.stencil" ]; then
if [ -e "/etc/stencil/.stencil" ]; then
cp /etc/stencil/.stencil /opt/stencil/
else
stencil init
fi
fi
stencil start
else
exec "$@"
fi
FROM ubuntu:xenial
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get update -qq
RUN apt-get install -y -qq git curl python python-pip build-essential
RUN pip install virtualenv
ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 4.1.2
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.28.0/install.sh | bash \
&& source $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/v$NODE_VERSION/bin:$PATH
RUN source $NVM_DIR/nvm.sh \
&& npm install -g bigcommerce/stencil-cli --loglevel=error
RUN mkdir -p /opt/stencil
WORKDIR "/opt/stencil"
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment