Created
July 13, 2017 21:15
-
-
Save heug/b31ba05d4f99563e1d5e0bc1498005f5 to your computer and use it in GitHub Desktop.
FundThatFlip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM buildpack-deps:jessie | |
# make Apt non-interactive | |
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90circleci \ | |
&& echo 'APT::Get::force-Yes "true";' >> /etc/apt/apt.conf.d/90circleci \ | |
&& echo 'DPkg::Options "--force-confnew";' >> /etc/apt/apt.conf.d/90circleci | |
ENV DEBIAN_FRONTEND=noninteractive | |
RUN apt-get update \ | |
&& apt-get install -y \ | |
git mercurial xvfb \ | |
locales sudo openssh-client ca-certificates tar gzip parallel \ | |
net-tools netcat unzip zip | |
# Set timezone to UTC by default | |
RUN ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime | |
# Use unicode | |
RUN locale-gen C.UTF-8 || true | |
ENV LANG=C.UTF-8 | |
# install jq | |
RUN JQ_URL=$(curl -sSL https://api.github.com/repos/stedolan/jq/releases/latest |grep browser_download_url |grep '/jq-linux64' | grep -o -e 'https.*jq-linux64') \ | |
&& curl -sSL --fail -o /usr/bin/jq $JQ_URL \ | |
&& chmod +x /usr/bin/jq | |
# install docker | |
RUN set -ex && DOCKER_VERSION=$(curl -sSL https://api.github.com/repos/docker/docker/releases/latest | jq -r '.tag_name' ) \ | |
&& DOCKER_URL="https://github.com/moby/moby/archive/${DOCKER_VERSION}.tar.gz" \ | |
&& curl -sSL -o /tmp/docker.tgz "${DOCKER_URL}" \ | |
&& echo $DOCKER_URL \ | |
&& ls -lha /tmp/docker.tgz \ | |
&& tar -xz -C /tmp -f /tmp/docker.tgz \ | |
&& mv /tmp/moby*/* /usr/bin \ | |
&& rm -rf /tmp/moby* /tmp/docker.tgz | |
# docker compose | |
RUN COMPOSE_URL=$(curl -sSL https://api.github.com/repos/docker/compose/releases/latest | jq -r '.assets[] | select(.name == "docker-compose-Linux-x86_64") | .browser_download_url') \ | |
&& curl -sSL -o /usr/bin/docker-compose $COMPOSE_URL \ | |
&& chmod +x /usr/bin/docker-compose | |
# install dockerize | |
RUN DOCKERIZE_URL=$(curl -sSL https://api.github.com/repos/jwilder/dockerize/releases/latest | jq -r '.assets[] | select(.name | startswith("dockerize-linux-amd64")) | .browser_download_url') \ | |
&& curl -sSL -o /tmp/dockerize-linux-amd64.tar.gz $DOCKERIZE_URL \ | |
&& tar -C /usr/local/bin -xzvf /tmp/dockerize-linux-amd64.tar.gz \ | |
&& rm -rf /tmp/dockerize-linux-amd64.tar.gz | |
RUN groupadd --gid 3434 circleci \ | |
&& useradd --uid 3434 --gid circleci --shell /bin/bash --create-home circleci \ | |
&& echo 'circleci ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-circleci \ | |
&& echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep | |
# BEGIN IMAGE CUSTOMIZATIONS | |
# Installing Ruby 2.2.5 from https://github.com/docker-library/ruby/blob/9898bab20a28b2df0b279dcca4b8dee399a4b4d0/2.2/Dockerfile | |
# skip installing gem documentation | |
RUN mkdir -p /usr/local/etc \ | |
&& { \ | |
echo 'install: --no-document'; \ | |
echo 'update: --no-document'; \ | |
} >> /usr/local/etc/gemrc | |
ENV RUBY_MAJOR 2.2 | |
ENV RUBY_VERSION 2.2.5 | |
ENV RUBY_DOWNLOAD_SHA256 30c4b31697a4ca4ea0c8db8ad30cf45e6690a0f09687e5d483c933c03ca335e3 | |
ENV RUBYGEMS_VERSION 2.6.8 | |
# some of ruby's build scripts are written in ruby | |
# we purge system ruby later to make sure our final image uses what we just built | |
RUN set -ex \ | |
\ | |
&& buildDeps=' \ | |
bison \ | |
libgdbm-dev \ | |
ruby \ | |
' \ | |
&& apt-get update \ | |
&& apt-get install -y --no-install-recommends $buildDeps \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
\ | |
&& wget -O ruby.tar.gz "https://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_VERSION.tar.gz" \ | |
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.gz" | sha256sum -c - \ | |
\ | |
&& mkdir -p /usr/src/ruby \ | |
&& tar -xzf ruby.tar.gz -C /usr/src/ruby --strip-components=1 \ | |
&& rm ruby.tar.gz \ | |
\ | |
&& cd /usr/src/ruby \ | |
\ | |
# hack in "ENABLE_PATH_CHECK" disabling to suppress: | |
# warning: Insecure world writable dir | |
&& { \ | |
echo '#define ENABLE_PATH_CHECK 0'; \ | |
echo; \ | |
cat file.c; \ | |
} > file.c.new \ | |
&& mv file.c.new file.c \ | |
\ | |
&& autoconf \ | |
&& ./configure --disable-install-doc \ | |
&& make -j"$(nproc)" \ | |
&& make install \ | |
\ | |
&& apt-get purge -y --auto-remove $buildDeps \ | |
&& cd / \ | |
&& rm -r /usr/src/ruby \ | |
\ | |
&& gem update --system "$RUBYGEMS_VERSION" | |
ENV BUNDLER_VERSION 1.12.4 | |
RUN gem install bundler --version "$BUNDLER_VERSION" | |
# install things globally, for great justice | |
# and don't create ".bundle" in all our apps | |
ENV GEM_HOME /usr/local/bundle | |
ENV BUNDLE_PATH="$GEM_HOME" \ | |
BUNDLE_BIN="$GEM_HOME/bin" \ | |
BUNDLE_SILENCE_ROOT_WARNING=1 \ | |
BUNDLE_APP_CONFIG="$GEM_HOME" | |
ENV PATH $BUNDLE_BIN:$PATH | |
RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \ | |
&& chmod 777 "$GEM_HOME" "$BUNDLE_BIN" | |
# install node 6.9.5 from https://github.com/nodejs/docker-node/blob/3b038b8a1ac8f65e3d368bedb9f979884342fdcb/6.9/Dockerfile | |
RUN groupadd --gid 1000 node \ | |
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node | |
# gpg keys listed at https://github.com/nodejs/node | |
RUN set -ex \ | |
&& for key in \ | |
9554F04D7259F04124DE6B476D5A82AC7E37093B \ | |
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ | |
0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \ | |
FD3A5288F042B6850C66B31F09FE44734EB7990E \ | |
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ | |
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ | |
B9AE9905FFD7803F25714661B63B535A4C206CA9 \ | |
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ | |
; do \ | |
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ | |
done | |
ENV NPM_CONFIG_LOGLEVEL info | |
ENV NODE_VERSION 6.9.5 | |
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \ | |
&& curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ | |
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ | |
&& grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ | |
&& tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \ | |
&& rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \ | |
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs | |
# BROWSERS | |
## Consider adding phantomjs | |
# | |
## install phantomjs | |
# | |
RUN export PHANTOMJS_VERSION=$(curl --location --fail --retry 3 https://api.github.com/repos/ariya/phantomjs/tags | jq -r '.[0].name') \ | |
&& sudo apt-get update; sudo apt-get install libfontconfig \ | |
&& curl --silent --show-error --location --fail --retry 3 --output /tmp/phantomjs.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2 \ | |
&& tar -x -C /tmp -f /tmp/phantomjs.tar.bz2 \ | |
&& sudo mv /tmp/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64/bin/phantomjs /usr/local/bin \ | |
&& rm -rf /tmp/phantomjs.tar.bz2 /tmp/phantomjs-* | |
# install firefox | |
# If you are upgrading to any version newer than 47.0.1, you must check the compatibility with | |
# selenium. See https://github.com/SeleniumHQ/selenium/issues/2559#issuecomment-237079591 | |
RUN curl --silent --show-error --location --fail --retry 3 --output /tmp/firefox.deb https://s3.amazonaws.com/circle-downloads/firefox-mozilla-build_47.0.1-0ubuntu1_amd64.deb \ | |
&& echo 'ef016febe5ec4eaf7d455a34579834bcde7703cb0818c80044f4d148df8473bb /tmp/firefox.deb' | sha256sum -c \ | |
&& sudo dpkg -i /tmp/firefox.deb || sudo apt-get -f install \ | |
&& sudo apt-get install -y libgtk3.0-cil-dev \ | |
&& rm -rf /tmp/firefox.deb | |
# install chrome | |
RUN curl --silent --show-error --location --fail --retry 3 --output /tmp/google-chrome-stable_current_amd64.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \ | |
&& (sudo dpkg -i /tmp/google-chrome-stable_current_amd64.deb || sudo apt-get -fy install) \ | |
&& rm -rf /tmp/google-chrome-stable_current_amd64.deb \ | |
&& sudo sed -i 's|HERE/chrome"|HERE/chrome" --disable-setuid-sandbox --no-sandbox|g' \ | |
"/opt/google/chrome/google-chrome" | |
RUN export CHROMEDRIVER_RELEASE=$(curl --location --fail --retry 3 http://chromedriver.storage.googleapis.com/LATEST_RELEASE) \ | |
&& curl --silent --show-error --location --fail --retry 3 --output /tmp/chromedriver_linux64.zip "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_RELEASE/chromedriver_linux64.zip" \ | |
&& cd /tmp \ | |
&& unzip chromedriver_linux64.zip \ | |
&& rm -rf chromedriver_linux64.zip \ | |
&& sudo mv chromedriver /usr/local/bin/chromedriver \ | |
&& sudo chmod +x /usr/local/bin/chromedriver | |
# start xvfb automatically to avoid needing to express in circle.yml | |
ENV DISPLAY :99 | |
RUN printf '#!/bin/sh\nXvfb :99 -screen 0 1280x1024x24 &\nexec "$@"\n' > /tmp/entrypoint \ | |
&& chmod +x /tmp/entrypoint \ | |
&& sudo mv /tmp/entrypoint /docker-entrypoint.sh | |
# ensure that the build agent doesn't override the entrypoint | |
LABEL com.circleci.preserve-entrypoint=true | |
ENTRYPOINT ["/docker-entrypoint.sh"] | |
# Workaround for npm installing npm in Docker (https://github.com/npm/npm/issues/15611#issuecomment-289133810) | |
RUN cd ~ | |
RUN npm install [email protected] | |
RUN rm -rf /usr/local/lib/node_modules | |
RUN mv node_modules /usr/local/lib/ | |
# Install Yarn | |
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - | |
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | |
RUN sudo apt-get install apt-transport-https | |
RUN sudo apt-get update | |
RUN sudo apt-get install yarn | |
# Install PostgreSQL Client | |
RUN sudo apt update | |
RUN sudo apt install postgresql-client | |
# END IMAGE CUSTOMIZATIONS | |
USER circleci | |
CMD ["/bin/sh"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment