CentOS in CI for Linux releases
Here are the dockerfiles I use. They're a hodge podge of copy-paste and hacks to get things working over the years. Odds are parts of it aren't needed anymore.
centos 6 (node <= 10)
FROM centos:6
### setup ###
RUN true && \
printf \
"\
[devtools-32]\n\
name=CentOS 5 devtools 32bit\n\
baseurl=http://people.centos.org/tru/devtools-2/6/i386/RPMS\n\
gpgcheck=0\n\
" > \
/etc/yum.repos.d/devtools32.repo && \
printf \
"\
[devtools-64]\n\
name=CentOS 5 devtools 64bit\n\
baseurl=http://people.centos.org/tru/devtools-2/6/x86_64/RPMS\n\
gpgcheck=0\n\
" > \
/etc/yum.repos.d/devtools64.repo
RUN yum install -y centos-release-scl
RUN yum install -y \
curl wget make file which python27 \
# curl wget make file which python26 \
devtoolset-2-{gcc,gcc.i686,gcc-c++,gcc-c++.i686,binutils,binutils.i686,libstdc++-devel,libstdc++-devel.i686} \
glibc-{devel,devel.i686} && \
yum clean all
### put cc/gcc in PATH ###
ENV PATH /opt/rh/devtoolset-2/root/usr/bin:$PATH
### install nvm ###
RUN mkdir ~/.nvm && \
wget --no-check-certificate -O ~/.nvm/nvm.sh https://raw.githubusercontent.com/xzyfer/nvm/master/nvm.sh
### make nvm work for iojs ###
RUN mkdir -p ~/.nvm/versions/{node,io.js}
### make nvm command avialable ###
ENV BASH_ENV="~/.bashrc"
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc
RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.bashrc
### allow mounting of node-sass ###
VOLUME /node-sass
### the main event
RUN source ~/.nvm/nvm.sh && nvm install 10
$ docker build --tag xzyfer/node-sass-10:latest - < Dockerfile
$ docker run -v ~/node-sass:/node-sass -w /node-sass -it --rm xzyfer/node-sass-10:latest scl enable python27 "nvm run stable ./scripts/build.js -f"
centos 7 (node > 10)
FROM centos:7
### setup ###
RUN yum install -y centos-release-scl
RUN yum install -y \
curl wget make file which \
devtoolset-7-{gcc,gcc.i686,gcc-c++,gcc-c++.i686,binutils,binutils.i686,libstdc++-devel,libstdc++-devel.i686} \
yum clean all
### put cc/gcc in PATH ###
ENV PATH /opt/rh/devtoolset-2/root/usr/bin:$PATH
# ENV PATH /opt/rh/devtoolset-6/root/usr/bin:$PATH
### install nvm ###
RUN mkdir ~/.nvm && \
wget --no-check-certificate -O ~/.nvm/nvm.sh https://raw.githubusercontent.com/xzyfer/nvm/master/nvm.sh
### make nvm work for iojs ###
RUN mkdir -p ~/.nvm/versions/{node,io.js}
### make nvm command avialable ###
ENV BASH_ENV="~/.bashrc"
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc
RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.bashrc
### allow mounting of node-sass ###
VOLUME /node-sass
### the main event
RUN source ~/.nvm/nvm.sh && nvm install 14
$ docker build --tag xzyfer/node-sass-14:latest - < Dockerfile
$ docker run -v ~/node-sass:/node-sass -w /node-sass -it --rm xzyfer/node-sass-14:latest scl enable devtoolset-7 -- nvm run stable ./scripts/build.js -f
Originally posted by @xzyfer in https://github.com/sass/node-sass/issues/3019#issuecomment-721675437
Started playing around with this over in https://github.com/nschonni/node-sass/tree/centos I tried to match the newer devtoolset-6/8 used by the upstream NodeJS versions that I saw in the compiler selector in nodejs/build. That hasn't worked out so well so far 😆
The problem is you can't use a newer C++ library coming with a toolset since most "normal" users will not have it...