From 91fd5e3f302536a005924912430ceb84ba3dc0da Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Tue, 30 May 2017 23:12:55 -0400 Subject: [PATCH] change gitiles to alpine Signed-off-by: Jess Frazelle --- gitiles/Dockerfile | 64 +++++++++++++++++++++++++++------------------- gitiles/start.sh | 4 +-- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/gitiles/Dockerfile b/gitiles/Dockerfile index f28fd01..815b34e 100644 --- a/gitiles/Dockerfile +++ b/gitiles/Dockerfile @@ -1,41 +1,51 @@ -FROM java:8 +FROM alpine:latest LABEL maintainer "Jessie Frazelle " -RUN apt-get update && apt-get install -y \ +ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk + +RUN apk add --no-cache \ + bash \ ca-certificates \ - --no-install-recommends \ - && rm -rf /var/lib/apt/lists/* + openjdk8 + +# https://github.com/bazelbuild/bazel/releases +ENV BAZEL_VERSION 0.5.0 +# https://gerrit.googlesource.com/gitiles/ +ENV GITILES_VERSION v0.2-1 # install bazel -RUN buildDeps=' \ - curl \ - ' \ - && set -x \ - && apt-get update && apt-get install -y $buildDeps --no-install-recommends \ - && rm -rf /var/lib/apt/lists/* \ - && curl -sSL https://bazel.build/bazel-release.pub.gpg | apt-key add - \ - && echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" >> /etc/apt/sources.list.d/bazel.list \ - && apt-get update && apt-get install -y \ - bazel \ - --no-install-recommends \ - && apt-get purge -y --auto-remove $buildDeps - -# install gitiles -RUN buildDeps=' \ +RUN set -x \ + && apk add --no-cache --virtual=.build-deps \ + build-base \ curl \ git \ + linux-headers \ + python \ zip \ - ' \ - set -x \ - && apt-get update && apt-get install -y $buildDeps --no-install-recommends \ - && rm -rf /var/lib/apt/lists/* \ - && git clone --depth 1 --recurse-submodules https://gerrit.googlesource.com/gitiles /usr/src/gitiles \ + && : install Bazel to build gitiles \ + && curl -sSL "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-dist.zip" -o /tmp/bazel.zip \ + && mkdir "/tmp/bazel-${BAZEL_VERSION}" \ + && unzip -qd "/tmp/bazel-${BAZEL_VERSION}" /tmp/bazel.zip \ + && rm -rf /tmp/bazel.zip \ + && ( \ + cd "/tmp/bazel-${BAZEL_VERSION}" \ + && : add -fpermissive compiler option to avoid compilation failure \ + && sed -i -e '/"-std=c++0x"/{h;s//"-fpermissive"/;x;G}' tools/cpp/cc_configure.bzl \ + && : add '#include ' to avoid mode_t type error \ + && sed -i -e '/#endif \/\/ COMPILER_MSVC/{h;s//#else/;G;s//#include /;G;}' third_party/ijar/common.h \ + && bash compile.sh \ + && cp -p output/bazel /usr/bin/ \ + ) \ + && git clone --depth 1 --branch "${GITILES_VERSION}" https://gerrit.googlesource.com/gitiles /usr/src/gitiles \ && ( \ cd /usr/src/gitiles \ - && git submodule update --init \ - && bazel build //... \ + && bazel build gitiles-dev:dev \ + && cp -rL bazel-bin bin \ + && rm -rf bazel-bin \ ) \ - && apt-get purge -y --auto-remove $buildDeps + && : clean up unneeded packages and files \ + && apk del .build-deps \ + && rm -rf /usr/bin/bazel /tmp/* /root/.cache "/tmp/bazel-${BAZEL_VERSION}" COPY start.sh /usr/bin/start.sh diff --git a/gitiles/start.sh b/gitiles/start.sh index cbae7cf..361c68d 100755 --- a/gitiles/start.sh +++ b/gitiles/start.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e ROOT=/usr/src/gitiles @@ -27,4 +27,4 @@ fi PROPERTIES="$PROPERTIES --jvm_flag=-Dcom.google.gitiles.sourcePath=$ROOT" -exec "${ROOT}/bazel-bin/gitiles-dev/dev" $PROPERTIES +exec "${ROOT}/bin/gitiles-dev/dev" $PROPERTIES