-
Notifications
You must be signed in to change notification settings - Fork 54
/
Dockerfile
84 lines (74 loc) · 2.74 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# vim: ft=dockerfile tw=78 ts=4 sw=4 et
# Supported Debian base images
# - stretch
# - jessie
ARG MERCURY_DEPEND_TAG=stretch
ARG MERCURY_DEV_PREFIX=/usr/local/mercury
ARG MERCURY_DEV_TARGET=/var/tmp/mercury
# first stage, base image
FROM debian:${MERCURY_DEPEND_TAG} AS base
RUN apt-get update && apt-get install -y \
apt-utils \
gcc \
libc-dev \
make \
pkg-config
FROM base AS bootstrap
ARG MERCURY_BOOTSTRAP=y
ARG MERCURY_DL=http://dl.mercurylang.org/deb/
ARG MERCURY_DEV_DEFAULT_GRADE=asm_fast.gc
ARG MERCURY_DEV_LIBGRADES=${MERCURY_DEV_DEFAULT_GRADE}
ARG MERCURY_DEV_PARALLEL=-j3
# When using a source tarball, the source needs to be the top level directory,
# e.g. `mercury-srcdist-rotd-2017-10-19'
ARG MERCURY_DEV_SOURCE=.
# inherited variables
ARG MERCURY_DEV_PREFIX
ARG MERCURY_DEV_TARGET
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE y
# install packaged compiler for bootstrapping
# first install curl and lsb-realse so we can add the public key for downloading
# Mercury packages.
# Then add the remote repository and install all packages required for building
# the Mercury compiler from source.
RUN ( echo 'debconf debconf/frontend select Noninteractive' \
| debconf-set-selections ) && \
apt-get update && apt-get install -y \
bison \
flex \
$([ "$MERCURY_BOOTSTRAP" != "y" ] || \
echo autoconf automake curl gnupg2 lsb-release) && \
[ "${MERCURY_BOOTSTRAP}" != "y" ] || \
( \
( curl -fsSL https://paul.bone.id.au/paul.asc | apt-key add - ) && \
printf "%s $MERCURY_DL $(lsb_release -cs) main\n" "deb" "deb-src" \
> /etc/apt/sources.list.d/mercury.list && \
apt-get update && apt-get install -y \
mercury-rotd-recommended \
)
WORKDIR $MERCURY_DEV_TARGET
COPY ${MERCURY_DEV_SOURCE} .
# Checking for configure enables using
# - `docker build http://uri.to.bootstrapped.tar.gz',
# - `docker build https://github.com/:user:/mercury.git'
# - `docker build .'
#
# Bootcheck fails currently: ( MAKE_DIR=`pwd`/scripts PATH=$PATH:`pwd`/scripts tools/bootcheck $MERCURY_DEV_PARALLEL ) \
RUN ( \
([ -f ./configure ] || ./prepare.sh) \
&& ./configure \
--enable-libgrades=$MERCURY_DEV_LIBGRADES \
--with-default-grade=$MERCURY_DEFAULT_GRADE \
--prefix=$MERCURY_DEV_PREFIX \
--disable-symlinks \
&& make PARALLEL=$MERCURY_DEV_PARALLEL install \
&& rm -fR ${MERCURY_BOOTSTRAP_TARGET} \
&& rm -fR $MERCURY_DEV_TARGET \
)
FROM base AS compiler
ARG MERCURY_DEV_PREFIX
ARG MERCURY_DEV_TARGET
WORKDIR $MERCURY_DEV_TARGET
COPY --from=bootstrap $MERCURY_DEV_PREFIX $MERCURY_DEV_PREFIX
ENV PATH ${MERCURY_DEV_PREFIX}/bin:$PATH
ENTRYPOINT ["mmc"]