Skip to content

Commit

Permalink
rework Docker image build system
Browse files Browse the repository at this point in the history
[docker:build-clang-5]
[docker:build-clang-6]
  • Loading branch information
kkaefer committed Sep 28, 2018
1 parent 08023be commit 85b8e72
Show file tree
Hide file tree
Showing 49 changed files with 278 additions and 582 deletions.
118 changes: 21 additions & 97 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,102 +4,26 @@ workflows:
version: 2
default:
jobs:
- start:
type: approval
- base:
requires:
- start
- linux:
requires:
- base
- linux-clang-3.8-libcxx:
requires:
- linux
- linux-clang-3.9:
requires:
- linux
- linux-clang-4:
requires:
- linux
- linux-clang-5:
requires:
- linux
- linux-gcc-4.9:
requires:
- linux
- linux-gcc-5:
requires:
- linux
- linux-gcc-5-qt-4:
requires:
- linux-gcc-5
- linux-gcc-5-qt-5.9:
requires:
- linux-gcc-5
- linux-gcc-6:
requires:
- linux
- linux-gcc-7:
requires:
- linux
- java:
requires:
- base
- android-ndk-r18:
requires:
- java

defaults: &defaults
working_directory: /app
docker:
- image: docker:17.10.0-ce-git
steps:
- checkout
- setup_remote_docker:
version: 17.10.0-ce # Some older versions don't support ARG before FROM in Dockerfiles
- run:
name: Log in to Docker Hub
command: docker login -u mbgl -p ${DOCKER_PASS}
- run:
name: Revision ID
command: echo "Building revision ${CIRCLE_SHA1:0:10}"
- run:
name: Build image
command: docker build -t mbgl/${CIRCLE_SHA1:0:10}:${CIRCLE_STAGE} --build-arg REV=${CIRCLE_SHA1:0:10} ${CIRCLE_STAGE}
no_output_timeout: 30m
- run:
name: Push image
command: docker push mbgl/${CIRCLE_SHA1:0:10}:${CIRCLE_STAGE}

- build

jobs:
base:
<<: *defaults

linux:
<<: *defaults
linux-clang-3.8-libcxx:
<<: *defaults
linux-clang-3.9:
<<: *defaults
linux-clang-4:
<<: *defaults
linux-clang-5:
<<: *defaults
linux-gcc-4.9:
<<: *defaults
linux-gcc-5:
<<: *defaults
linux-gcc-5-qt-4:
<<: *defaults
linux-gcc-5-qt-5.9:
<<: *defaults
linux-gcc-6:
<<: *defaults
linux-gcc-7:
<<: *defaults

java:
<<: *defaults
android-ndk-r18:
<<: *defaults
build:
working_directory: /app
docker:
- image: docker:18.05.0-ce-git
steps:
- checkout
- run:
name: Install dependencies
command: apk add --no-progress bash curl jq
- run:
name: Prepare environment
command: touch "$BASH_ENV" && scripts/environment.sh | tee -a "$BASH_ENV"
- setup_remote_docker:
version: 18.05.0-ce
- run:
name: Log in to Docker Hub
command: docker login -u mbgl -p ${DOCKER_PASS}
- run:
name: Build Docker images
command: scripts/build.sh
45 changes: 0 additions & 45 deletions README.md

This file was deleted.

49 changes: 0 additions & 49 deletions android-ndk-r18/Dockerfile

This file was deleted.

45 changes: 0 additions & 45 deletions base/Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion base/nodesource-v8.list

This file was deleted.

Binary file removed base/nodesource.gpg
Binary file not shown.
76 changes: 76 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash

set -eu
cd "$(dirname "${BASH_SOURCE[0]}")"

PUSH=false
ID="${CIRCLE_SHA1:-latest}"

function usage {
echo "Usage: $0 [args] <image>"
echo ""
echo "Arguments:"
echo " -p, --push Pushes the resulting image to Docker Hub (only for builds with an ID)"
echo " -i, --id Specifies the ID of the image. Defaults to \`${CIRCLE_SHA1:-latest}\`"
exit 1
}

declare -a ARGS
while [ $# -gt 0 ]; do
case "$1" in
-p|--push)
PUSH=true
shift
;;
-i|--id)
if [ -z "${2:-}" ]; then
echo -e "\033[31m$1 is missing an argument\033[0m\n"
usage
fi
ID="${2}"
shift
shift
;;
-*)
echo "Unknown argument $1"
usage
;;
*)
ARGS+=("$1")
shift
;;
esac
done
if [ ${#ARGS[@]} -ne 0 ]; then
set -- "${ARGS[@]}"
fi

if [ -z "${1:-}" ]; then
usage
fi
IMAGE="$1"

if [ ! -r "images/$IMAGE" ]; then
echo "Can't find image $IMAGE"
exit 1
fi

if [ $PUSH = true ] && [ "$ID" == "latest" ]; then
echo -e "\033[31mCan't push images without a named ID. Try setting CIRCLE_SHA1 to the commit sha\033[0m\n"
usage
fi


# Add HTTP proxy for local testing if there is an apt-proxy running.
PREFIX=
if nc -z localhost 3142 2>/dev/null; then
PREFIX=$'\n''RUN echo "Acquire::http { Proxy \\"http://host.docker.internal:3142\\"; };" >> /etc/apt/apt.conf.d/01proxy'
fi


# Add prefix to the Docker file and pipe it into stdin
sed -e '/^FROM /a\'"$PREFIX" "images/$IMAGE" | docker build -t "mbgl/$IMAGE:${ID:0:10}" images -f -

if [ $PUSH = true ]; then
docker push "mbgl/$IMAGE:${ID:0:10}"
fi
48 changes: 48 additions & 0 deletions images/build-clang-5
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM ubuntu:bionic-20180821
ENV DEBIAN_FRONTEND="noninteractive"

# libsysconfcpus.so can be used to alter the number of CPUs reported by the system
COPY libsysconfcpus.so /usr/lib/
ENV LD_PRELOAD=/usr/lib/libsysconfcpus.so

RUN set -eu \
&& apt-get update \
&& apt-get -y install git make curl python ccache zlib1g-dev libcurl4-openssl-dev \
&& rm -rf /var/lib/apt/lists/*

# Install Node.js
# Check https://nodejs.org/en/download/releases/ for releases + hashes
RUN set -eu && VERSION=8.12.0 HASH=3df19b748ee2b6dfe3a03448ebc6186a3a86aeab557018d77a0f7f3314594ef6 \
&& SLUG=node-v$VERSION-linux-x64 \
&& curl -L --retry 3 -O https://nodejs.org/dist/v$VERSION/$SLUG.tar.gz \
&& (echo "$HASH $SLUG.tar.gz" | shasum -c) \
&& tar xzf $SLUG.tar.gz --strip-components=1 -C /usr $SLUG/bin $SLUG/lib $SLUG/share \
&& rm $SLUG.tar.gz

# Install CMake
# Check https://cmake.org/download/ for releases + hashes
RUN set -eu && MAJOR=3 MINOR=12 PATCH=2 HASH=5bd6e37590b929e26e67fbbff1278e77858ab40430f103ea20a9928435e64662 \
&& SLUG=cmake-$MAJOR.$MINOR.$PATCH-Linux-x86_64 \
&& curl -L --retry 3 -O https://cmake.org/files/v$MAJOR.$MINOR/$SLUG.tar.gz \
&& (echo "$HASH $SLUG.tar.gz" | shasum -c) \
&& tar xzf $SLUG.tar.gz --strip-components=1 -C /usr $SLUG/bin/cmake $SLUG/share/cmake-$MAJOR.$MINOR \
&& rm $SLUG.tar.gz

# Install OpenGL-related packages
RUN set -eu \
&& apt-get update \
&& apt-get -y install libx11-dev libgl1-mesa-dev libxrandr-dev libxcursor-dev libxinerama-dev libxi-dev \
&& rm -rf /var/lib/apt/lists/*

# Install Clang
RUN set -eu \
&& apt-get update \
&& apt-get -y install clang-5.0 clang-tidy-5.0 clang-format-5.0 \
&& rm -rf /var/lib/apt/lists/*

ENV CC="clang-5.0" \
CXX="clang++-5.0" \
CLANG_FORMAT="clang-format-5.0" \
CLANG_TIDY="clang-tidy-5.0"

WORKDIR /src
Loading

0 comments on commit 85b8e72

Please sign in to comment.