Skip to content

Instantly share code, notes, and snippets.

@dlindahl
Created September 29, 2017 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlindahl/9fc8c5b289ae5517db04affb62de9d49 to your computer and use it in GitHub Desktop.
Save dlindahl/9fc8c5b289ae5517db04affb62de9d49 to your computer and use it in GitHub Desktop.
Example node/docker setup
# https://medium.com/@fbzga/how-to-cache-bundle-install-with-docker-7bed453a5800
# https://github.com/zacksiri/docker-ruby-node/blob/master/Dockerfile
# https://github.com/mwallasch/docker-ruby-node/blob/master/Dockerfile
# https://github.com/shawnzhu/docker-ruby-nodejs/blob/master/Dockerfile
# http://bitjudo.com/blog/2014/03/13/building-efficient-dockerfiles-node-dot-js/
FROM ubuntu:16.04
MAINTAINER ETA
WORKDIR /tmp
RUN apt-get update
RUN apt-get install -y --no-install-recommends apt-utils git curl wget sudo
# Install Ruby
RUN \
apt-get update && \
apt-get install -y ruby ruby-dev && \
rm -rf /var/lib/apt/lists/*
RUN ruby -v
RUN gem -v
# Install Node
RUN curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
RUN sudo apt-get install -y nodejs
RUN node -v
# Install Bundler
RUN apt-get install -y libgmp-dev make gcc build-essential patch zlib1g-dev locales
RUN echo "en_US UTF-8" > /etc/locale.gen
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV BUNDLE_PATH /box
#ENV GEM_PATH /box
#ENV GEM_HOME /box
ENV PATH /box:$PATH
RUN echo $PATH
RUN gem install bundler
RUN bundle -v
RUN bundle config --global silence_root_warning 1
# Configure NPM
ENV NPM_CONFIG_PREFIX /box/node_modules
ENV PATH /box/node_modules:$PATH
# Install Yarn
RUN apt-get install -y apt-transport-https
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y yarn
RUN yarn -v
# Install Ruby dependencies
ADD Gemfile .
ADD Gemfile.lock .
RUN bundle check || bundle install
# Install Node dependencies
# TODO: http://stackoverflow.com/questions/14742553/npm-local-install-package-to-custom-location into /box
ADD package.json .
ADD yarn.lock .
RUN yarn install
# Cache dependency installation
# #ADD . /repo
WORKDIR /repo
RUN cp /tmp/package.json .
RUN cp /tmp/yarn.lock .
# RUN cp /tmp/node_modules .
# Run the site generator
EXPOSE 4000
VOLUME /repo
CMD bundle exec jekyll serve -H 0.0.0.0 -P 4000
#ENTRYPOINT ls -la
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment