Skip to content

Instantly share code, notes, and snippets.

@am11
Last active December 15, 2016 23:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save am11/1529b2458b1a1f4bdba8 to your computer and use it in GitHub Desktop.
Save am11/1529b2458b1a1f4bdba8 to your computer and use it in GitHub Desktop.
node-sass docker for Linux binaries
# day 1 with docker (vagrant guy here)
FROM centos:5
### setup ###
RUN yum install -y curl wget make file which
RUN rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
#RUN curl -SL https://rpm.nodesource.com/setup | bash -
RUN printf \
"[devtools-32]\n\
name=CentOS 5 devtools 32bit\n\
baseurl=http://people.centos.org/tru/devtools-2/5/i386/RPMS\n\
gpgcheck=0\n" > \
/etc/yum.repos.d/devtools32.repo
RUN printf \
"[devtools-64]\n\
name=CentOS 5 devtools 64bit\n\
baseurl=http://people.centos.org/tru/devtools-2/5/x86_64/RPMS\n\
gpgcheck=0\n" >\
/etc/yum.repos.d/devtools64.repo
RUN yum install -y devtoolset-2-{gcc,gcc-c++,binutils} git python26
RUN yum install -y glibc-devel.i386 devtoolset-2-libstdc++-devel.i386
ENV PATH /opt/rh/devtoolset-2/root/usr/bin:$PATH
### install nvm ###
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.24.0/install.sh | bash
ENV NVM_NODEJS_ORG_MIRROR="https://nodejs.org/dist"
RUN cp /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.bak
RUN wget -O /etc/pki/tls/certs/ca-bundle.crt http://curl.haxx.se/ca/cacert.pem
### build node-sass ###
RUN git clone https://github.com/sass/node-sass --recursive
WORKDIR /node-sass
RUN mv /usr/bin/python /usr/bin/python_ && mv /usr/bin/python26 /usr/bin/python
RUN git submodule update --init --recursive
ENV PATH /opt/centos/devtoolset-1.0/root/usr/bin:$PATH
RUN source ~/.nvm/nvm.sh && nvm install v0 && npm install && \
node scripts/build.js -f
RUN source ~/.nvm/nvm.sh && nvm install v0.10 && \
node scripts/build.js -f
RUN source ~/.nvm/nvm.sh && nvm install iojs-v1 && \
node scripts/build.js -f
RUN source ~/.nvm/nvm.sh && nvm install iojs-v1.0 && \
node scripts/build.js -f
# now manually install x86 versions and build binaries #
RUN source ~/.nvm/nvm.sh && \
wget http://nodejs.org/dist/v0.10.37/node-v0.10.37-linux-x86.tar.gz && \
tar -C ~/.nvm/versions/node -xvf node-v0.10.37-linux-x86.tar.gz && \
mv ~/.nvm/versions/node/node-v0.10.37-linux-x86 ~/.nvm/versions/node/v0.12.37-x86 && \
ls ~/.nvm/versions/node && \
nvm use v0.12.37-x86 && \
node scripts/build.js -f
RUN source ~/.nvm/nvm.sh && \
wget http://nodejs.org/dist/v0.12.1/node-v0.12.1-linux-x86.tar.gz && \
tar -C ~/.nvm/versions/node -xvf node-v0.12.1-linux-x86.tar.gz && \
mv ~/.nvm/versions/node/node-v0.12.1-linux-x86 ~/.nvm/versions/node/v0.12.1-x86 && \
ls ~/.nvm/versions/node && \
nvm use v0.12.1-x86 && \
node scripts/build.js -f
RUN source ~/.nvm/nvm.sh && \
wget https://iojs.org/dist/v1.0.4/iojs-v1.0.4-linux-x86.tar.gz && \
tar -C ~/.nvm/versions/io.js -xvf iojs-v1.0.4-linux-x86.tar.gz && \
mv ~/.nvm/versions/io.js/iojs-v1.0.4-linux-ia32 ~/.nvm/versions/io.js/v1.0.4-x86 && \
nvm use iojs-v1.0.4-x86 && \
node scripts/build.js -f
RUN source ~/.nvm/nvm.sh && \
wget https://iojs.org/dist/v1.6.2/iojs-v1.6.2-linux-x86.tar.gz && \
tar -C ~/.nvm/versions/io.js -xvf iojs-v1.6.2-linux-x86.tar.gz && \
mv ~/.nvm/versions/io.js/iojs-v1.6.2-linux-ia32 ~/.nvm/versions/io.js/v1.6.2-x86 && \
nvm use iojs-v1.6.2-x86 && \
node scripts/build.js -f
RUN ls vendor
RUN tar -cvzf binaries.tar.gz vendor/
@am11
Copy link
Author

am11 commented Mar 25, 2015

How to run?

  • Install docker: http://docs.docker.com/installation/

  • Create a Dockerfile into an empty directory, and copy paste this gist's content, save and close file.

  • In shell, run:

    docker build --tag node-sass-binaries .
    
    docker run node-sass-binaries cat /node-sass/binaries.tar.gz > binaries.tar.gz
    
    tar -zxvf binaries.tar.gz
    
  • To disable incremental (cache-able) build, use:

    docker build --tag node-sass-binaries --no-cache --rm=true .
    
    docker run node-sass-binaries cat /node-sass/binaries.tar.gz > binaries.tar.gz
    
    tar -zxvf binaries.tar.gz
    

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