Skip to content
Permalink
Browse files

Added a docker build environemnt

  • Loading branch information...
LaurentGoderre committed Jan 19, 2017
1 parent a7dfc47 commit 526a7bc2db75e48e7dca71ee2e8e391fae7a70c2
@@ -0,0 +1,136 @@
FROM node:6

RUN npm install -g \
grunt-cli \
bower \
&& npm cache clean

#
# Java
#


# A few problems with compiling Java from source:
# 1. Oracle. Licensing prevents us from redistributing the official JDK.
# 2. Compiling OpenJDK also requires the JDK to be installed, and it gets
# really hairy.

RUN apt-get update && apt-get install -y --no-install-recommends \
bzip2 \
unzip \
xz-utils \
&& rm -rf /var/lib/apt/lists/*

RUN echo 'deb http://deb.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/jessie-backports.list

# Default to UTF-8 file.encoding
ENV LANG C.UTF-8

# add a simple script that can auto-detect the appropriate JAVA_HOME value
# based on whether the JDK or only the JRE is installed
RUN { \
echo '#!/bin/sh'; \
echo 'set -e'; \
echo; \
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
} > /usr/local/bin/docker-java-home \
&& chmod +x /usr/local/bin/docker-java-home

ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/jre

ENV JAVA_VERSION 8u121
ENV JAVA_DEBIAN_VERSION 8u121-b13-1~bpo8+1

# see https://bugs.debian.org/775775
# and https://github.com/docker-library/java/issues/19#issuecomment-70546872
ENV CA_CERTIFICATES_JAVA_VERSION 20161107~bpo8+1

RUN set -x \
&& apt-get update \
&& apt-get install -y \
openjdk-8-jre-headless="$JAVA_DEBIAN_VERSION" \
ca-certificates-java="$CA_CERTIFICATES_JAVA_VERSION" \
&& rm -rf /var/lib/apt/lists/* \
&& [ "$JAVA_HOME" = "$(docker-java-home)" ]

# see CA_CERTIFICATES_JAVA_VERSION notes above
RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure

# If you're reading this and have any feedback on how this image could be
# improved, please open an issue or a pull request so we can discuss it!

#
# Ruby
#

# 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.4
ENV RUBY_VERSION 2.4.0
ENV RUBY_DOWNLOAD_SHA256 3a87fef45cba48b9322236be60c455c13fd4220184ce7287600361319bb63690
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 \
xz-utils \
' \
&& apt-get update \
&& apt-get install -y --no-install-recommends $buildDeps \
&& rm -rf /var/lib/apt/lists/* \
\
&& wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \
\
&& mkdir -p /usr/src/ruby \
&& tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \
&& rm ruby.tar.xz \
\
&& 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 --enable-shared \
&& 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.13.7

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"

RUN gem install rake html-proofer
@@ -0,0 +1,6 @@
FROM node:6

RUN npm install -g \
grunt-cli \
bower \
&& npm cache clean
@@ -0,0 +1,42 @@
#!/bin/bash
# strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
IFS=$'\n\t'
if [ ! -n "${ZSH_VERSION-}" ] ; then
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
else
dir="$( cd "$( dirname "${(%):-%N}" )" && pwd )"
fi
project="${PWD##*/}"
bins=("npm" "bower" "grunt")

deactivate () {
for bin in "${bins[@]}"
do
unalias "$bin"
done

if ! [ -z "${_OLD_PS1+_}" ] ; then
PS1="$_OLD_PS1"
export PS1
unset _OLD_PS1
fi
}

if ( [ ! -n "${ZSH_VERSION-}" ] && [ "$(type -t npm)" == "alias" ] ) ||
( [ -n "${ZSH_VERSION-}" ] && [ "$(type -w npm)" = "npm: alias" ] ); then
echo "Already activated!"
else
for bin in "${bins[@]}"
do
alias "$bin=$dir/$bin"
done

_OLD_PS1="$PS1"
PS1_APPEND="(Docker WET-BOEW $project)"
if [ ! -n "${ZSH_VERSION-}" ] ; then
PS1="\e[1;35m$PS1_APPEND\e[0m $PS1"
else
PS1="%F{magenta}$PS1_APPEND%F{white} $PS1"
fi
export PS1
fi
@@ -0,0 +1,34 @@
#!/bin/bash
if ! type docker > /dev/null; then
echo "Docker is required to be present on $PATH"
exit 0
fi


docker build \
-t wet-boew-build \
--build-arg http_proxy="$HTTP_PROXY" \
--build-arg HTTP_PROXY="$HTTP_PROXY" \
--build-arg https_proxy="$HTTP_PROXY" \
--build-arg HTTPS_PROXY="$HTTP_PROXY" \
$src

run () {
docker run -it \
-v "${PWD}":"/home/node/app" \
-w "/home/node/app" \
-u node \
-v /tmp/:/tmp/ \
-v $HOME/.gitconfig:/home/node/.gitconfig \
-v $HOME/.npmrc:/home/node/.npmrc \
-v $HOME/.netrc:/home/node/.netrc \
-e HTTP_PROXY=$HTTP_PROXY \
-e HTTPS_PROXY=$HTTP_PROXY \
-e http_proxy=$HTTP_PROXY \
-e https_proxy=$HTTP_PROXY \
--sig-proxy=true \
--pid=host \
--rm \
$extra_params \
wet-boew-build $@
}
@@ -0,0 +1,5 @@
#!/bin/bash
src="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $src/base.sh

run $(basename $0) $@
@@ -0,0 +1,9 @@
#!/bin/bash
src="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $src/base.sh

args=${@:-default}

extra_params="-p 8000:8000"

run $(basename $0) $args
@@ -0,0 +1,5 @@
#!/bin/bash
src="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $src/base.sh

run $(basename $0) $@
@@ -0,0 +1,10 @@
#!/bin/sh
cp Dockerfile.template Dockerfile

echo "\n#\n# Java\n#\n" >> Dockerfile
curl -sSL --compressed https://raw.githubusercontent.com/docker-library/openjdk/445f8b8d18d7c61e2ae7fda76d8883b5d51ae0a5/8-jre/Dockerfile | tail -n +8 >> Dockerfile

echo "\n#\n# Ruby\n#\n" >> Dockerfile
curl -sSL --compressed https://raw.githubusercontent.com/docker-library/ruby/bfc7a48724ceb1917ddbcb713b24c835eca584c8/2.4/Dockerfile | tail -n +3 | head -n -1 >> Dockerfile

echo "RUN gem install rake html-proofer" >> Dockerfile

0 comments on commit 526a7bc

Please sign in to comment.
You can’t perform that action at this time.