Skip to content

Commit 66a23d4

Browse files
author
Christos KK Loverdos
committed
[CGKIELE-166] Decrease mantis image build times
by pre-generating another image with lot's of dependencies included. Unfortunately the final image size increases, thus nullifying the previous effort.
1 parent 3e3a3eb commit 66a23d4

File tree

5 files changed

+87
-50
lines changed

5 files changed

+87
-50
lines changed

docker/Dockerfile

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
FROM ubuntu:xenial
2-
3-
ENV DEBIAN_FRONTEND noninteractive
4-
5-
ARG SBT_VERIFY_TAG
6-
ENV SBT_VERIFY_TAG ${SBT_VERIFY_TAG:-v0.4.1}
1+
FROM mantis-dev:2018-04-25.3e3a3eb
72

83
ARG MANTIS_TAG
94
ENV MANTIS_TAG ${MANTIS_TAG:-phase/iele_testnet}
@@ -19,38 +14,9 @@ ENV MANTIS_TAG ${MANTIS_TAG:-phase/iele_testnet}
1914
ARG MANTIS_DIST_ZIP_NAME
2015
ENV MANTIS_DIST_ZIP_NAME ${MANTIS_DIST_ZIP_NAME:-mantis-*}
2116

22-
# Just install enough to get nix up and running
23-
RUN apt-get update \
24-
&& apt-get dist-upgrade -y \
25-
&& apt-get install -y curl bzip2 locales \
26-
&& locale-gen en_US.UTF-8 \
27-
&& update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 \
28-
&& adduser --disabled-password --gecos '' mantis \
29-
&& mkdir /nix \
30-
&& chown mantis:mantis /nix \
31-
&& su mantis -c 'curl https://nixos.org/nix/install | sh && . ~/.nix-profile/etc/profile.d/nix.sh && nix-channel --update && tail -n 1 ~/.profile >> ~/.bashrc' \
32-
&& ln -s /home/mantis/mantis-dist/app /app \
33-
&& apt-get purge -y curl bzip2 \
34-
&& apt-get clean -y \
35-
&& rm -rf /var/cache/debconf/* /var/lib/apt/lists/* /var/log/* /tmp/* /var/tmp/*
36-
37-
USER mantis
38-
WORKDIR /home/mantis
39-
ENV USER mantis
40-
41-
# install java, sbt, git, unzip
42-
RUN . ~/.nix-profile/etc/profile.d/nix.sh \
43-
&& nix-env -i openjdk-8u172b02 sbt-1.1.4 git unzip \
44-
&& nix-collect-garbage
45-
4617
# TODO: Could just use a nix-shell and garbage collect (e.g. git, unzip, sbt) after the installations ...
4718
RUN . ~/.nix-profile/etc/profile.d/nix.sh \
48-
&& mkdir repos && cd repos \
49-
&& git clone https://github.com/input-output-hk/sbt-verify.git \
50-
&& cd sbt-verify \
51-
&& git checkout $SBT_VERIFY_TAG \
52-
&& sbt publishLocal \
53-
&& cd - \
19+
&& cd repos \
5420
&& git clone https://github.com/input-output-hk/mantis.git \
5521
&& cd mantis \
5622
&& git checkout $MANTIS_TAG \

docker/Dockerfile-dev

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM ubuntu:xenial
2+
3+
# This "dev" image creates enough of a Mantis build environment,
4+
# so that the actual Mantis images can be built in less time.
5+
# We are particularly interested in caching the dependencies needed
6+
# during the build process. This means that whenever those change,
7+
# the "dev" image must be recreated.
8+
9+
# See the accompanying `build-dev.sh` script for tagging details.
10+
11+
ENV DEBIAN_FRONTEND noninteractive
12+
13+
ARG SBT_VERIFY_TAG
14+
ENV SBT_VERIFY_TAG ${SBT_VERIFY_TAG:-v0.4.1}
15+
16+
ARG MANTIS_TAG
17+
ENV MANTIS_TAG ${MANTIS_TAG:-phase/iele_testnet}
18+
19+
# Just install enough to get nix up and running
20+
RUN apt-get update \
21+
&& apt-get dist-upgrade -y \
22+
&& apt-get install -y curl bzip2 locales \
23+
&& locale-gen en_US.UTF-8 \
24+
&& update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 \
25+
&& adduser --disabled-password --gecos '' mantis \
26+
&& mkdir /nix \
27+
&& chown mantis:mantis /nix \
28+
&& su mantis -c 'curl https://nixos.org/nix/install | sh && . ~/.nix-profile/etc/profile.d/nix.sh && nix-channel --update && tail -n 1 ~/.profile >> ~/.bashrc' \
29+
&& ln -s /home/mantis/mantis-dist/app /app \
30+
&& apt-get purge -y curl bzip2 \
31+
&& apt-get clean -y \
32+
&& rm -rf /var/cache/debconf/* /var/lib/apt/lists/* /var/log/* /tmp/* /var/tmp/*
33+
34+
USER mantis
35+
WORKDIR /home/mantis
36+
ENV USER mantis
37+
38+
# install java, sbt, git, unzip
39+
RUN . ~/.nix-profile/etc/profile.d/nix.sh \
40+
&& nix-env -i openjdk-8u172b02 sbt-1.1.4 git unzip \
41+
&& nix-collect-garbage
42+
43+
# TODO: Could just use a nix-shell and garbage collect (e.g. git, unzip, sbt) after the installations ...
44+
RUN . ~/.nix-profile/etc/profile.d/nix.sh \
45+
&& mkdir repos && cd repos \
46+
&& git clone https://github.com/input-output-hk/sbt-verify.git \
47+
&& cd sbt-verify \
48+
&& git checkout $SBT_VERIFY_TAG \
49+
&& sbt publishLocal \
50+
&& cd - \
51+
&& git clone https://github.com/input-output-hk/mantis.git \
52+
&& cd mantis \
53+
&& git checkout $MANTIS_TAG \
54+
&& git submodule update --init \
55+
&& sbt 'set test in Test := {}' dist \
56+
&& cd ~ \
57+
&& rm -rf ~/repos/*

docker/build-dev.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux
4+
5+
HERE=$(readlink -m $(dirname ${BASH_SOURCE[0]}))
6+
7+
exec $HERE/buildhelper.sh mantis-dev Dockerfile-dev

docker/build.sh

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,4 @@ set -eux
44

55
HERE=$(readlink -m $(dirname ${BASH_SOURCE[0]}))
66

7-
IMAGE_NAME=mantis
8-
DOCKERFILE=Dockerfile
9-
10-
# If IMAGE_TAG is not given in the command line, then compute one in the format
11-
#
12-
# YYYY-MM-DD '.' SHORT_HASH
13-
#
14-
# where the variable parts refer to the latest commit
15-
IMAGE_TAG=${1:-$(git log -1 --format=%cd.%h --date=short)}
16-
17-
# This is the commit that the image will be based on
18-
COMMIT=$(git log -1 --format=%H)
19-
20-
docker build --build-arg MANTIS_TAG=${COMMIT} -t $IMAGE_NAME:$IMAGE_TAG -f $HERE/$DOCKERFILE $HERE
7+
$HERE/buildhelper.sh mantis Dockerfile

docker/buildhelper.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux
4+
5+
HERE=$(readlink -m $(dirname ${BASH_SOURCE[0]}))
6+
7+
IMAGE_NAME=$1
8+
DOCKERFILE=$2
9+
10+
# If IMAGE_TAG is not given in the command line, then compute one in the format
11+
#
12+
# YYYY-MM-DD '.' SHORT_HASH
13+
#
14+
# where the variable parts refer to the latest commit
15+
IMAGE_TAG=${3:-$(git log -1 --format=%cd.%h --date=short)}
16+
17+
# This is the commit that the image will be based on
18+
GIT_HASH=$(git log -1 --format=%H)
19+
20+
docker build --build-arg MANTIS_TAG=$GIT_HASH -t $IMAGE_NAME:$IMAGE_TAG -f $HERE/$DOCKERFILE $HERE

0 commit comments

Comments
 (0)